23 lines
575 B
PHP
Executable File
23 lines
575 B
PHP
Executable File
<?php
|
|
|
|
namespace App\Models\Admin;
|
|
|
|
use Dcat\Admin\Admin;
|
|
use Dcat\Admin\Models\Menu as DcatMenu;
|
|
|
|
class Menu extends DcatMenu
|
|
{
|
|
public function fetchAll()
|
|
{
|
|
return $this->withQuery(function ($query) {
|
|
if (!Admin::user()->isAdministrator()) {
|
|
return $query->with('roles')->whereHas('roles', function ($q) {
|
|
$q->whereIn('id', Admin::user()->roles()->pluck('id')->toArray());
|
|
});
|
|
} else {
|
|
return $query->with('roles');
|
|
}
|
|
})->treeAllNodes();
|
|
}
|
|
}
|