<?php

namespace Modules\Canteen\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;
use Modules\Order\Models\Order;
use Modules\School\Models\School;
use Modules\User\Models\User;

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

    protected $fillable = [
        'code',
        'image',
        'wallet',
        'account_name',
        'account_number',
        'bank_name',
        'iban',
        'school_id',
        'user_id',
        'active'
    ];


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

    public function school()
    {
        return $this->belongsTo(School::class, 'school_id')->withTrashed();
    }
    public function user()
    {
        return $this->belongsTo(User::class, 'user_id')->withTrashed();
    }

    public function orders()
    {
        return $this->hasMany(Order::class);
    }
}
