diff --git a/app/Models/TeamMember.php b/app/Models/TeamMember.php index d2510426fa1..84030ee2257 100644 --- a/app/Models/TeamMember.php +++ b/app/Models/TeamMember.php @@ -24,4 +24,13 @@ public function user(): BelongsTo { return $this->belongsTo(User::class, 'user_id'); } + + public function userOrDeleted(): User + { + $user = $this->user; + + return $user === null || $user->isRestricted() + ? new DeletedUser(['user_id' => $this->user_id]) + : $user; + } } diff --git a/resources/views/teams/members/index.blade.php b/resources/views/teams/members/index.blade.php index b470ff76f9d..cc549d03c58 100644 --- a/resources/views/teams/members/index.blade.php +++ b/resources/views/teams/members/index.blade.php @@ -24,23 +24,26 @@ {{ osu_trans('teams.members.index.table.joined_at') }} @foreach ($team->members as $member) + @php + $user = $member->userOrDeleted(); + @endphp
  • user->user_avatar) !!} + {!! background_image($user->user_avatar) !!} > - {!! link_to_user($member->user, null, '', []) !!} + {!! link_to_user($user, null, '', []) !!} - {{ osu_trans('teams.members.index.status.status_'.(int) $member->user->isActive()) }} - @if ($member->user->isOnline()) + {{ osu_trans('teams.members.index.status.status_'.(int) $user->isActive()) }} + @if ($user->isOnline()) ({!! osu_trans('users.show.lastvisit_online') !!}) - @elseif (($lastvisit = $member->user->displayed_last_visit) !== null) + @elseif (($lastvisit = $user->displayed_last_visit) !== null) ({!! osu_trans('users.show.lastvisit', ['date' => timeago($lastvisit)]) !!}) diff --git a/resources/views/teams/show.blade.php b/resources/views/teams/show.blade.php index ba1153f329c..45b1d84f37d 100644 --- a/resources/views/teams/show.blade.php +++ b/resources/views/teams/show.blade.php @@ -3,16 +3,15 @@ See the LICENCE file in the repository root for full licence text. --}} @php - use App\Models\DeletedUser; use App\Transformers\UserCompactTransformer; $userTransformer = new UserCompactTransformer(); $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, + $member->user_id === $team->leader_id ? 'leader' : 'member' => $member->userOrDeleted(), ])->all()); $teamMembers['member'] ??= []; - $teamMembers['leader'] ??= $toJson([$team->leader ?? new DeletedUser(['user_id' => $team->leader_id])]); + $teamMembers['leader'] ??= $toJson([$team->members()->make(['user_id' => $team->leader_id])->userOrDeleted()]); $headerUrl = $team->header()->url(); @endphp