Skip to content

Commit

Permalink
fix: update show
Browse files Browse the repository at this point in the history
  • Loading branch information
deniskorbakov committed Oct 27, 2024
1 parent e233ca2 commit 615e364
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/Api/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function teamIsCaptain(int $id): array

public function show(int $id): array
{
$user = User::query()->findOrFail($id);
$user = User::query()->find($id);

return $this->userService->show($user);
}
Expand Down
8 changes: 6 additions & 2 deletions app/Services/Api/UserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@

class UserService
{
public function show(User $user): array
public function show(User|null $user): array
{
return UserShowDTO::from($user)->toArray();
if ($user) {
return UserShowDTO::from($user)->toArray();
}

return [];
}

public function achievement(Team|null $team, User|null $user): array
Expand Down

0 comments on commit 615e364

Please sign in to comment.