Skip to content

Commit

Permalink
Fix handling of team leader
Browse files Browse the repository at this point in the history
  • Loading branch information
nanaya committed Dec 6, 2024
1 parent a0c02ab commit b194ea3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions app/Models/Team.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use App\Libraries\BBCodeForDB;
use App\Libraries\Uploader;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Team extends Model
Expand Down
11 changes: 5 additions & 6 deletions resources/views/teams/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
use App\Transformers\UserCompactTransformer;
$userTransformer = new UserCompactTransformer();
$teamMembers = array_map(
fn ($users) => json_collection($users, $userTransformer, UserCompactTransformer::CARD_INCLUDES),
$team->members->mapToGroups(fn ($member) => [
$member->user_id === $team->leader_id ? 'leader' : 'member' => $member->user,
])->all(),
);
$toJson = fn ($users) => json_collection($users, $userTransformer, UserCompactTransformer::CARD_INCLUDES);
$teamMembers = array_map($toJson, $team->members->mapToGroups(fn ($member) => [
$member->user_id === $team->leader_id ? 'leader' : 'member' => $member->user,
])->all());
$teamMembers['member'] ??= [];
$teamMembers['leader'] ??= $toJson([$team->leader ?? new DeletedUser(['user_id' => $team->leader_id])]);
$headerUrl = $team->header()->url();
@endphp

Expand Down

0 comments on commit b194ea3

Please sign in to comment.