refactor: fix BelongsToTenant trait to exempt candidates globally - removes all withoutGlobalScopes() workarounds

This commit is contained in:
jeremy bayse
2026-04-14 19:38:42 +02:00
parent 49ee91c601
commit e93a17f324
3 changed files with 11 additions and 29 deletions

View File

@@ -51,18 +51,7 @@ Route::get('/dashboard', function () {
$candidate = auth()->user()->candidate;
if ($candidate) {
// Load without global tenant scope so candidates (who may have no tenant_id)
// can still see the quizzes linked to their job position
$candidate->load(['jobPosition' => function($query) {
$query->withoutGlobalScopes();
}]);
if ($candidate->jobPosition) {
$candidate->jobPosition->setRelation(
'quizzes',
$candidate->jobPosition->quizzes()->withoutGlobalScopes()->get()
);
}
$candidate->load('jobPosition.quizzes');
}
$quizzes = ($candidate && $candidate->jobPosition)