23 lines
716 B
PHP
23 lines
716 B
PHP
<?php
|
|
|
|
namespace IriksIT\Manager\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use IriksIT\Manager\Support\Menu;
|
|
use IriksIT\Manager\Support\ModuleRegistry;
|
|
|
|
class DashboardController
|
|
{
|
|
public function __invoke(Request $request, ModuleRegistry $modules, Menu $menu)
|
|
{
|
|
$user = $request->user();
|
|
|
|
// Only what this account may reach, in the face it looks at.
|
|
$navigation = $menu->for($user, array_values(array_filter($modules->permissionValues(), fn (string $permission) => $user?->can($permission))));
|
|
|
|
return $request->wantsJson()
|
|
? response()->json(['navigation' => $navigation])
|
|
: view('manager::dashboard', ['navigation' => $navigation]);
|
|
}
|
|
}
|