✏️ 编辑:MenuItem.php
路径:
/home/boguraj1/.trash/app/Models/MenuItem.php
大小:729 B · 修改:2026-07-23 16:13:46 · 权限:0644 · 可写
← 返回目录
👁 查看
⬇ 下载
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class MenuItem extends Model { protected $fillable = [ 'label', 'url', 'route_name', 'location', 'icon', 'target', 'sort_order', 'is_enabled', ]; protected $casts = [ 'is_enabled' => 'boolean', ]; public static function forLocation(string $location) { return static::where('location', $location) ->where('is_enabled', true) ->orderBy('sort_order') ->get(); } public function isActive(): bool { if ($this->route_name) { return request()->routeIs($this->route_name); } return request()->url() === $this->url; } }
💾 保存
取消
保存为 UTF-8,换行统一为 LF