<?php

namespace Modules\School\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;
use Modules\Canteen\Models\Canteen;
use Modules\User\Models\User;
use Modules\City\Models\City;

class School extends Model
{
    //use soft delete
    use SoftDeletes;

    protected $fillable = [
        'code',
        'city_id',
        'active'
    ];


    /**
     * Get current description of the the Room
     * @return HasOne
     */
    public function currentDescription(): HasOne
    {
        return $this->hasOne(SchoolDescription::class)->where('language_id', currentLanguage()->id);
    }

    public function city()
    {
        return $this->belongsTo(City::class, 'city_id')->withTrashed();
    }
    public function canteen(): HasOne
    {
        return $this->hasOne(Canteen::class, 'school_id');
    }

}
