Skip to content

Commit

Permalink
🐛 Fix status sorting on profiles page (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKrisKrisu authored Sep 30, 2021
1 parent 2a1fc59 commit 77d8065
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,24 @@ public static function statusesForUser(User $user): ?LengthAwarePaginator {
throw new PermissionException();
}
return $user->statuses()
->join('train_checkins', 'statuses.id', '=', 'train_checkins.status_id')
->with([
'user', 'likes', 'trainCheckin.Origin', 'trainCheckin.Destination',
'trainCheckin.HafasTrip.stopoversNEW', 'event'
])
->where(function($query) {
$user = Auth::check() ? auth()->user()->id : null;
$query->whereIn('visibility', [StatusVisibility::PUBLIC, StatusVisibility::UNLISTED])
->orWhere('user_id', $user)
$query->whereIn('statuses.visibility', [StatusVisibility::PUBLIC, StatusVisibility::UNLISTED])
->orWhere('statuses.user_id', $user)
->orWhere(function($query) {
$followings = Auth::check() ? auth()->user()->follows()->select('follow_id') : [];
$query->where('visibility', StatusVisibility::FOLLOWERS)
->whereIn('user_id', $followings);
$query->where('statuses.visibility', StatusVisibility::FOLLOWERS)
->whereIn('statuses.user_id', $followings);
});
})->orderByDesc('created_at')->paginate(15);
})
->select('statuses.*')
->orderByDesc('train_checkins.departure')
->paginate(15);
}

/**
Expand Down

0 comments on commit 77d8065

Please sign in to comment.