cms-laravel/app/Livewire/MainSidebar.php

129 lines
4.3 KiB
PHP

<?php
namespace App\Livewire;
use Livewire\Component;
class MainSidebar extends Component
{
public $collapsed = false;
public $userInfo;
public $systemPreferences;
public $navigation = [
[
'key' => 0,
'label' => 'User Management',
'path' => '/user-management',
'icon' => 'bi-people',
'access' => true,
],
[
'key' => 9,
'label' => 'Notifications',
'path' => '/notifications',
'icon' => 'bi-bell',
'access' => true,
],
[
'key' => 4,
'label' => 'Member Management',
'path' => '/member-management',
'icon' => 'bi-credit-card',
'access' => true,
'child' => [
['key' => 0.0, 'label' => 'Card Member', 'path' => '/member-management/card-member', 'access' => true],
['key' => 0.1, 'label' => 'Locked Accounts', 'path' => '/member-management/lock-account', 'access' => true],
],
],
[
'key' => 8,
'label' => 'Home Page (Mobile)',
'path' => '/home-page',
'icon' => 'bi-house',
'access' => true,
'child' => [
['key' => 0.0, 'label' => 'Photo Slider', 'path' => '/home-page/photo-slider', 'access' => true],
],
],
[
'key' => 3,
'label' => 'Promotions',
'path' => '/promotions',
'icon' => 'bi-tags',
'access' => true,
],
[
'key' => 2,
'label' => 'Top-Up',
'path' => '/top-up',
'icon' => 'bi-plus-circle',
'access' => true,
],
[
'key' => 6,
'label' => 'About Us',
'path' => '/about-us',
'icon' => 'bi-info-circle',
'access' => true,
'child' => [
['key' => 0.6, 'label' => 'Card Types', 'path' => '/about-us/card-types', 'access' => true],
['key' => 0.5, 'label' => 'Terms & Privacy', 'path' => '/about-us/term-privacy', 'access' => true],
],
],
[
'key' => 7,
'label' => 'Reports',
'path' => '/reports',
'icon' => 'bi-file-text',
'access' => true,
'child' => [
['key' => 0.7, 'label' => 'Registration Report', 'path' => '/reports/registration-report', 'access' => true],
['key' => 0.8, 'label' => 'Top-Up Usage Report', 'path' => '/reports/top-up', 'access' => true],
['key' => 0.9, 'label' => 'Mobile Usage Report', 'path' => '/reports/mobile-report', 'access' => true],
['key' => 0.1, 'label' => 'Station Rating Report', 'path' => '/reports/station-rating', 'access' => true],
],
],
[
'key' => 8,
'label' => 'System Parameters',
'path' => '/system-parameters',
'icon' => 'bi-gear',
'access' => true,
],
[
'key' => 12,
'label' => 'Station Locator',
'path' => '',
'icon' => 'bi-geo-alt',
'access' => true,
'child' => [
['key' => 0.11, 'label' => 'Branches', 'path' => '/branches', 'access' => true],
['key' => 0.12, 'label' => 'Stations', 'path' => '/stations', 'access' => true],
['key' => 0.13, 'label' => 'Fuels', 'path' => '/fuels', 'access' => true],
],
],
];
public function mount($collapsed = false, $userInfo = [], $systemPreferences = null)
{
$this->collapsed = $collapsed;
$this->userInfo = $userInfo;
$this->systemPreferences = $systemPreferences;
// Filter navigation based on access (static for frontend)
$this->navigation = array_filter($this->navigation, fn($item) => $this->hasAccess($item));
}
private function hasAccess($item)
{
// Static access logic based on role (frontend-only simulation)
$role = $this->userInfo['role'] ?? 0;
return $item['access'] && ($role === 1 || !$item['access']);
}
public function render()
{
return view('livewire.main-sidebar');
}
}