<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Menu extends Model
{
    public $table = 'menus';

    public $fillable = [
        'name',
        'detail',
        'image_name',
        'status',
        'branch_id'
    ];

    protected $casts = [
        'name' => 'string',
        'detail' => 'string',
        'image_name' => 'string',
        'status' => 'boolean'
    ];

    public static array $rules = [
        'name' => 'required|string|max:255',
        'status' => 'nullable|boolean',
        'branch_id' => 'nullable',
        'created_at' => 'nullable',
        'updated_at' => 'nullable'
    ];

    public function branch()
  {
    return $this->belongsTo(Branches::class, 'branch_id', 'id');
  }

  public function categories(){
    return $this->hasMany(Categories::class,'menu_id','id');
  }

}
