add controllers, servoices
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\RoleModel;
|
||||
|
||||
class RoleService
|
||||
{
|
||||
public function __construct(private RoleModel $roles = new RoleModel()) {}
|
||||
|
||||
/** @param string[] $roleKeys names or slugs */
|
||||
public function bestDashboardRouteFor(array $roleKeys): string
|
||||
{
|
||||
$rows = $this->roles->findByNamesOrSlugs($roleKeys);
|
||||
if (!empty($rows)) {
|
||||
// first row is highest priority due to orderBy('priority','ASC')
|
||||
return $rows[0]['dashboard_route'] ?? '/landing_page/guest_dashboard';
|
||||
}
|
||||
return '/landing_page/guest_dashboard';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user