Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter out restricted user from Playlist scores #11488

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ public function index($roomId, $playlistId)
$limit = clamp(get_int($params['limit'] ?? null) ?? 50, 1, 50);
$cursorHelper = PlaylistItemUserHighScore::makeDbCursorHelper($params['sort'] ?? null);

$highScoresQuery = $playlist->highScores()->whereHas('scoreLink');
$highScoresQuery = $playlist
->highScores()
->whereHas('user', function ($userQuery) {
$userQuery->default();
})
notbakaneko marked this conversation as resolved.
Show resolved Hide resolved
->whereHas('scoreLink');

[$highScores, $hasMore] = $highScoresQuery
->clone()
Expand Down
6 changes: 6 additions & 0 deletions app/Models/Multiplayer/PlaylistItemUserHighScore.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use App\Models\Model;
use App\Models\Traits\WithDbCursorHelper;
use App\Models\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

Expand Down Expand Up @@ -130,4 +131,9 @@ public function updateWithScoreLink(ScoreLink $scoreLink): bool
'total_score' => $score->total_score,
])->save();
}

public function user(): BelongsTo
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right, this should be in relation function area?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we still doing that 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so for scopes, relations and laravel model setters/getters? 🤔

{
return $this->belongsTo(User::class, 'user_id');
}
}