<?php

namespace App\Models\Webprofile;

use App\Http\Traits\UuidTrait;
use App\Models\Webprofile\En\Menu as EnMenu;
use Illuminate\Database\Eloquent\Model;

class Menu extends Model
{
    use UuidTrait;

    public $incrementing = false;
    protected $table = 'swp_menus';

    protected $fillable = [
        'id', 'name', 'url', 'mode', 'status', 'parent', 'urutan', 'parentlevel', 'level', 'userid_created', 'userid_updated',
    ];

    public static $rules = [
        // 'name' => 'required',
    ];

    public static $errormessage = [
        'required' => 'Form Input Ini Tidak Boleh Kosong / Harus Diisi',
    ];

    public function rEn()
    {
        return $this->hasOne(EnMenu::class, 'menu_id', 'id');
    }

    public function rChild()
    {
        return $this->hasMany(Menu::class, 'parent', 'id')->orderBy('urutan', 'asc')->with(['rChild', 'rEn']);
    }
}
