fix: null quiz crash in admin candidate show - load attempts.quiz withoutGlobalScopes + null guard in Vue template
This commit is contained in:
@@ -81,13 +81,23 @@ class CandidateController extends Controller
|
|||||||
$candidate->load([
|
$candidate->load([
|
||||||
'user',
|
'user',
|
||||||
'documents',
|
'documents',
|
||||||
'attempts.quiz',
|
|
||||||
'attempts.answers.question',
|
|
||||||
'attempts.answers.option',
|
|
||||||
'jobPosition',
|
'jobPosition',
|
||||||
'tenant'
|
'tenant'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// Load attempts with quiz bypassing tenant scope
|
||||||
|
// (admin may view candidates whose quizzes belong to other tenants)
|
||||||
|
$candidate->setRelation(
|
||||||
|
'attempts',
|
||||||
|
$candidate->attempts()
|
||||||
|
->with([
|
||||||
|
'quiz' => fn($q) => $q->withoutGlobalScopes(),
|
||||||
|
'answers.question',
|
||||||
|
'answers.option',
|
||||||
|
])
|
||||||
|
->get()
|
||||||
|
);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'candidate' => $candidate,
|
'candidate' => $candidate,
|
||||||
'jobPositions' => \App\Models\JobPosition::all(),
|
'jobPositions' => \App\Models\JobPosition::all(),
|
||||||
|
|||||||
@@ -818,7 +818,7 @@ const runAI = async () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h4 class="text-xl font-black uppercase tracking-tight">{{ attempt.quiz.title }}</h4>
|
<h4 class="text-xl font-black uppercase tracking-tight">{{ attempt.quiz?.title ?? 'Quiz supprimé' }}</h4>
|
||||||
<div class="text-xs text-slate-400 mt-1 uppercase font-bold tracking-widest">
|
<div class="text-xs text-slate-400 mt-1 uppercase font-bold tracking-widest">
|
||||||
Fini le {{ formatDateTime(attempt.finished_at) }}
|
Fini le {{ formatDateTime(attempt.finished_at) }}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user