2024-07-30 16:13:21 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
|
|
|
use Closure;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use SteelAnts\LaravelBoilerplate\Facades\Menu;
|
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
|
|
|
|
class GenerateMenus
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Handle an incoming request.
|
|
|
|
*
|
|
|
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
|
|
|
*/
|
|
|
|
public function handle(Request $request, Closure $next): Response
|
|
|
|
{
|
|
|
|
if ($request->route()->getName() === 'livewire.message') {
|
2024-08-07 19:56:13 +00:00
|
|
|
return $next($request);
|
2024-07-30 16:13:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!auth()->check()) {
|
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
|
|
|
|
Menu::make('main-menu', function ($menu) {
|
|
|
|
$systemRoutes = [
|
2024-08-07 19:56:13 +00:00
|
|
|
'boilerplate::ui.home' => [' fas fa-home', 'dashboard'],
|
2024-07-31 15:04:33 +00:00
|
|
|
'boilerplate::ui.planned' => [' fas fa-home', 'maintenance.planned'],
|
|
|
|
];
|
|
|
|
|
|
|
|
foreach ($systemRoutes as $title => $route_data) {
|
|
|
|
$icon = $route_data[0];
|
|
|
|
$route = $route_data[1];
|
|
|
|
|
|
|
|
$menu = $menu->add($title, [
|
|
|
|
'id' => strtolower($title),
|
|
|
|
'icon' => $icon,
|
|
|
|
'route' => $route,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Menu::make('settings-menu', function ($menu) {
|
|
|
|
$systemRoutes = [
|
|
|
|
'Host' => [' fas fa-server', 'host'],
|
|
|
|
'Maintenance' => [' fas fa-calendar', 'maintenance'],
|
2024-08-06 14:57:48 +00:00
|
|
|
'Tasks' => [' fas fa-list', 'tasks'],
|
2024-07-30 16:13:21 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
foreach ($systemRoutes as $title => $route_data) {
|
|
|
|
$icon = $route_data[0];
|
|
|
|
$route = $route_data[1];
|
|
|
|
|
|
|
|
$menu = $menu->add($title, [
|
|
|
|
'id' => strtolower($title),
|
|
|
|
'icon' => $icon,
|
|
|
|
'route' => $route,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
//CHECK IF USER IS SYSTEM ADMIN
|
|
|
|
Menu::make('system-menu', function ($menu) {
|
|
|
|
$systemRoutes = [
|
|
|
|
'boilerplate::ui.audit' => ['fas fa-eye', 'system.audit.index'],
|
|
|
|
'boilerplate::ui.api' => ['fas fa-file-archive', 'system.api.index'],
|
|
|
|
'boilerplate::ui.user' => ['fas fa-users', 'system.user.index'],
|
|
|
|
'boilerplate::subscriptions.title' => ['fas fa-dollar-sign', 'system.subscription.index'],
|
|
|
|
'boilerplate::ui.log' => ['fas fa-bug', 'system.log.index'],
|
|
|
|
'boilerplate::ui.jobs' => ['fas fa-business-time', 'system.jobs.index'],
|
|
|
|
'boilerplate::ui.cache' => ['fas fa-box', 'system.cache.index'],
|
|
|
|
'boilerplate::ui.backup' => ['fas fa-file-archive', 'system.backup.index']
|
|
|
|
];
|
|
|
|
foreach ($systemRoutes as $title => $route_data) {
|
|
|
|
$icon = $route_data[0];
|
|
|
|
$route = $route_data[1];
|
|
|
|
|
|
|
|
$menu = $menu->add($title, [
|
|
|
|
'id' => strtolower($title),
|
|
|
|
'icon' => $icon,
|
|
|
|
'route' => $route,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
}
|