get(); } catch (\Throwable $e) { Log::error('Error fetching permissions: ' . $e->getMessage()); throw $e; } } /** * Fetch permissions assigned to a specific role. * Returns rows similar to legacy: * role_permissions.* + permissions.name */ public static function getRolePermissions(int $roleId): array { try { $rows = DB::table('role_permissions') ->leftJoin('permissions', 'role_permissions.permission_id', '=', 'permissions.id') ->where('role_permissions.role_id', $roleId) ->select('role_permissions.*', 'permissions.name') ->get() ->map(fn ($r) => (array) $r) ->all(); Log::info('Role permissions fetched: ' . print_r($rows, true)); return $rows; } catch (\Throwable $e) { Log::error("Error fetching role permissions for role ID {$roleId}: " . $e->getMessage()); throw $e; } } }