fix: bypass BelongsToTenant global scope when loading candidate quizzes on dashboard - candidates have no tenant_id
This commit is contained in:
@@ -51,7 +51,18 @@ Route::get('/dashboard', function () {
|
||||
$candidate = auth()->user()->candidate;
|
||||
|
||||
if ($candidate) {
|
||||
$candidate->load('jobPosition.quizzes');
|
||||
// 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()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$quizzes = ($candidate && $candidate->jobPosition)
|
||||
|
||||
Reference in New Issue
Block a user