forked from admin/services_core
63 lines
1.2 KiB
PHP
63 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Traits\Auditable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class MenuList extends Model
|
|
{
|
|
use Auditable;
|
|
|
|
protected $table = 'menu_lists';
|
|
|
|
protected $fillable = [
|
|
'parent_id',
|
|
'name',
|
|
'slug',
|
|
'url',
|
|
'icon',
|
|
'component',
|
|
'sort_order',
|
|
'is_active',
|
|
];
|
|
|
|
protected $casts = [
|
|
'is_active' => 'boolean',
|
|
'sort_order' => 'integer',
|
|
];
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Relationships
|
|
|--------------------------------------------------------------------------
|
|
*/
|
|
|
|
public function parent()
|
|
{
|
|
return $this->belongsTo(self::class, 'parent_id');
|
|
}
|
|
|
|
public function children()
|
|
{
|
|
return $this->hasMany(self::class, 'parent_id');
|
|
}
|
|
|
|
public function menuGroups()
|
|
{
|
|
return $this->belongsToMany(
|
|
MenuGroup::class,
|
|
'menu_group_menus',
|
|
'menu_id',
|
|
'menu_group_id'
|
|
)->withPivot([
|
|
'can_view',
|
|
'can_create',
|
|
'can_update',
|
|
'can_delete',
|
|
'can_approve',
|
|
'can_export',
|
|
])->withTimestamps();
|
|
}
|
|
}
|