MicroFrameWork/kernel/models/Menu.php

46 lines
1.1 KiB
PHP
Raw Normal View History

2024-08-30 12:27:46 +03:00
<?php
namespace kernel\models;
use app\helpers\Debug;
use Illuminate\Database\Eloquent\Model;
2024-08-30 16:14:31 +03:00
/**
* @property int $id
* @property int parent_id
* @property string icon_file
* @property string icon_font
* @property string label
* @property string url
* @property int status
* @method static find($id)
*/
2024-08-30 12:27:46 +03:00
class Menu extends Model
{
protected $table = 'menu';
protected $fillable = ['parent_id', 'icon_file', 'icon_font', 'label', 'url', 'status'];
protected array $dates = ['deleted_at'];
public static function labels(): array
{
return [
'parent_id' => 'Родительский пункт меню',
'icon_file' => 'Путь к иконке',
'icon_font' => 'Иконка',
'label' => 'Заголовок',
'url' => 'URL',
'status' => 'Статус',
];
}
public static function getChild(int $id)
{
$collection = Menu::where("parent_id", $id)->get();
if (!$collection->isEmpty()){
return $collection;
}
return false;
}
}