60 lines
2.0 KiB
PHP
60 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Livewire\Menu;
|
|
|
|
use App\Utilities\SystemAccess;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\Support\Str;
|
|
use Livewire\Component;
|
|
|
|
class Settings extends Component
|
|
{
|
|
public $keyword = '';
|
|
|
|
public $active_menu = 0;
|
|
|
|
protected $listeners = ['resetKeyword'];
|
|
|
|
public function render(): View
|
|
{
|
|
menu()->create('settings', function ($menu) {
|
|
$menu->style('tailwind');
|
|
|
|
if (! SystemAccess::canOpenSettings()) {
|
|
return;
|
|
}
|
|
|
|
$items = [
|
|
['system-settings.users.index', '用户管理', 'people', '用户 类型 权限'],
|
|
['system-settings.permissions.index', '权限管理', 'admin_panel_settings', '侧边栏 用户页面 访问权限 管理员 身份'],
|
|
['system-settings.databases.index', '数据库管理', 'storage', '系统数据库 云数据库 上游 连接 测试'],
|
|
];
|
|
|
|
foreach ($items as $index => [$route, $title, $icon, $keywords]) {
|
|
if ($this->keyword && ! Str::contains(Str::lower($title . ' ' . $keywords), Str::lower($this->keyword))) {
|
|
continue;
|
|
}
|
|
|
|
$item = $menu->route($route, $title, [], ($index + 1) * 10, [
|
|
'icon' => $icon,
|
|
'search_keywords' => $keywords,
|
|
'active' => fn () => request()->routeIs(Str::beforeLast($route, '.') . '.*')
|
|
|| ($route === 'system-settings.users.index' && request()->routeIs('system-settings.groups.*'))
|
|
|| ($route === 'system-settings.permissions.index' && request()->routeIs('system-settings.sidebar.*')),
|
|
]);
|
|
|
|
if ($item->isActive()) {
|
|
$this->active_menu = 1;
|
|
}
|
|
}
|
|
});
|
|
|
|
return view('livewire.menu.settings');
|
|
}
|
|
|
|
public function resetKeyword(): void
|
|
{
|
|
$this->keyword = '';
|
|
}
|
|
}
|