fix teacher and parent routes

This commit is contained in:
root
2026-04-24 02:12:01 -04:00
parent 5128c74892
commit 7216cb2885
36 changed files with 1575 additions and 49 deletions
@@ -8,17 +8,18 @@ class UserWithRolesResource extends JsonResource
{
public function toArray($request): array
{
$roles = $this['roles'] ?? [];
$row = is_array($this->resource) ? $this->resource : (array) $this->resource;
$roles = $row['roles'] ?? [];
if (is_string($roles)) {
$roles = array_filter(array_map('trim', explode(',', $roles)));
}
return [
'id' => (int) ($this['id'] ?? 0),
'firstname' => (string) ($this['firstname'] ?? ''),
'lastname' => (string) ($this['lastname'] ?? ''),
'email' => (string) ($this['email'] ?? ''),
'account_id' => (string) ($this['account_id'] ?? ''),
'id' => (int) ($row['id'] ?? 0),
'firstname' => (string) ($row['firstname'] ?? ''),
'lastname' => (string) ($row['lastname'] ?? ''),
'email' => (string) ($row['email'] ?? ''),
'account_id' => (string) ($row['account_id'] ?? ''),
'roles' => array_values(array_filter($roles)),
];
}