fix teacher and parent routes
This commit is contained in:
@@ -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)),
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user