diff --git a/src/Http/Resources/AuthorResource.php b/src/Http/Resources/AuthorResource.php index f76764f..729eae7 100644 --- a/src/Http/Resources/AuthorResource.php +++ b/src/Http/Resources/AuthorResource.php @@ -16,14 +16,12 @@ public function toArray($request): array { /** @var User $this */ - $role = $this->roles->first()->name ?? null; - return [ 'id' => $this->id, 'first_name' => $this->first_name, 'last_name' => $this->last_name, 'image' => $this->avatar_url, - 'role' => $role, + 'role' => $this->roles?->first()?->name ?? null, ]; } }