Skip to content

Commit

Permalink
fix: optimize role name for author data
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhongit committed Dec 7, 2024
1 parent 53a5918 commit 2ded76a
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/Http/Resources/AuthorResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ public function toArray($request): array
{
/** @var User $this */

$role = $this->roles->first()->name ?? null;

return [
'id' => $this->id,

Check failure on line 20 in src/Http/Resources/AuthorResource.php

View workflow job for this annotation

GitHub Actions / PHPStan - P8.3

Access to an undefined property CSlant\Blog\Core\Models\User::$id.
'first_name' => $this->first_name,

Check failure on line 21 in src/Http/Resources/AuthorResource.php

View workflow job for this annotation

GitHub Actions / PHPStan - P8.3

Access to an undefined property CSlant\Blog\Core\Models\User::$first_name.
'last_name' => $this->last_name,

Check failure on line 22 in src/Http/Resources/AuthorResource.php

View workflow job for this annotation

GitHub Actions / PHPStan - P8.3

Access to an undefined property CSlant\Blog\Core\Models\User::$last_name.
'image' => $this->avatar_url,
'role' => $role,
'role' => $this->roles?->first()?->name ?? null,
];
}
}

0 comments on commit 2ded76a

Please sign in to comment.