Files
alrahma_sunday_school_api/app/Services/Roles/RoleSwitchService.php
T
2026-03-11 17:53:15 -04:00

24 lines
553 B
PHP

<?php
namespace App\Services\Roles;
use App\Models\UserRole;
class RoleSwitchService
{
public function __construct(private RoleDashboardService $dashboardService)
{
}
public function getUserRoleNames(int $userId): array
{
$roles = UserRole::getRolesByUserId($userId);
return array_values(array_filter(array_map(fn ($r) => (string) ($r['role_name'] ?? ''), $roles)));
}
public function switchRole(string $role): string
{
return $this->dashboardService->bestDashboardRouteFor([$role]);
}
}