2025-09-02 11:25:28 +08:00
|
|
|
|
<?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);
|
|
|
|
|
}
|
2025-09-02 13:12:06 +08:00
|
|
|
|
if (auth()->check() && !auth()->user()->hasRole('User')) {
|
2025-09-02 11:25:28 +08:00
|
|
|
|
$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');
|
|
|
|
|
}
|
|
|
|
|
}
|