Skip to content

Commit

Permalink
fix: update logic team
Browse files Browse the repository at this point in the history
  • Loading branch information
deniskorbakov committed Oct 27, 2024
1 parent a2bc5ce commit 1f0c0c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 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 @@ -40,7 +40,7 @@ public function update(int $id, UserUpdateDTO $userUpdateDTO): array|JsonRespons

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

return $this->userService->team($teams);
}
Expand Down
10 changes: 7 additions & 3 deletions app/Services/Api/UserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,15 @@ public function update(User|null $user, UserUpdateDTO $userUpdateDTO): array|Jso
return response()->json(['message' => 'just meme'], 403);
}

public function team(User $user): array
public function team(User|null $user): array
{
$team = $user->teams()->get();
if($user) {
$team = $user->teams()->get();

return UserTeamDTO::collect($team)->toArray();
return UserTeamDTO::collect($team)->toArray();
}

return [];
}

public function teamIsCaptain(User $user): array
Expand Down

0 comments on commit 1f0c0c8

Please sign in to comment.