KTVCentral/app/Livewire/Layout/Navigation.php
allen.yan 77bf255d60 202509021310
調整檔案位置
2025-09-02 13:12:06 +08:00

60 lines
2.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Livewire\Layout;
use Livewire\Component;
use App\Livewire\Actions\Logout;
class Navigation extends Component
{
private array $commonMenus = [
['name' => '首頁', 'route' => 'welcome'],
['name' => '新歌快報', 'route' => 'new-songs'],
['name' => '熱門排行', 'route' => 'top-ranking'],
['name' => '歌名查詢', 'route' => 'search-song'],
];
private array $roomMenus = [
['name' => '已點歌曲', 'route' => 'clicked-song'],
['name' => '聲音控制', 'route' => 'sound-control'],
['name' => '真情告白', 'route' => 'love-message'],
];
public array $adminmenus=[
['name' => '操作紀錄', 'route' => 'admin.activity-log', 'icon' => 'clock', 'permission' => null],
['name' => '包廂狀態紀錄', 'route' => 'admin.room-status-log', 'icon' => 'clock', 'permission' => null],
['name' => '設備狀態紀錄', 'route' => 'admin.machine-status', 'icon' => 'clock', 'permission' => null],
['name' => '使用者列表', 'route' => 'admin.users', 'icon' => 'user-circle', 'permission' => 'user-list'],
['name' => 'Room', 'route' => 'admin.rooms', 'icon' => 'building-library', 'permission' => 'room-list'],
['name' => 'RoomGrid', 'route' => 'admin.room-grids', 'icon' => 'film', 'permission' => 'room-list'],
['name' => '文字廣告', 'route' => 'admin.text-ads', 'icon' => 'megaphone', 'permission' => 'text-ad-list'],
['name' => '文字公告', 'route' => 'admin.broadcast-templates', 'icon' => 'megaphone', 'permission' => 'broadcast-list'],
];
public array $menus = [];
public function mount()
{
// 先放共用的
$this->menus = $this->commonMenus;
// 如果有 room_code再合併
if (session()->has('room_code')) {
$this->menus = array_merge($this->menus, $this->roomMenus);
}
if (auth()->check() && !auth()->user()->hasRole('User')) {
$user = auth()->user();
foreach ($this->adminmenus as $menu)
if (!$menu['permission'] || $user->can($menu['permission']))
$this->menus[] = $menu;
}
}
public function logout(Logout $logout)
{
$logout();
return redirect('/');
}
public function render()
{
return view('livewire.layout.navigation');
}
}