- Added `DefaultUserRole` and permissions enums (`AccessManager`, `Apps`, `Settings`) for centralizing role and permission constants. - Implemented `DashboardRoute` helper to resolve routes dynamically based on user roles. - Introduced seeders for default roles (`DefaultRoleWithPermissionSeeder`, `PermissionSeeder`, `ExampleUserWithRoleSeeder`) with role-permission assignments. - Created `EnumExtractor` utility for parsing enums and generating permissions. - Customized dashboard routes with role-based redirection logic. - Updated sidebar navigation to display role-based menu items with permission checks.
27 lines
561 B
PHP
27 lines
561 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Helpers;
|
|
|
|
use App\Enums\DefaultUserRole;
|
|
use Illuminate\Support\Collection;
|
|
|
|
class DashboardRoute
|
|
{
|
|
/**
|
|
* This function will resolve the dashboard route based on the user role.
|
|
*/
|
|
public static function resolve(Collection $roles): string
|
|
{
|
|
if ($roles->contains(DefaultUserRole::Admin->value)) {
|
|
return 'dashboard.admin';
|
|
}
|
|
if ($roles->contains(DefaultUserRole::User->value)) {
|
|
return 'dashboard.user';
|
|
}
|
|
|
|
return 'home';
|
|
}
|
|
}
|