feat: allow super admin to update candidate tenant on profile page
This commit is contained in:
@@ -84,10 +84,11 @@ class CandidateController extends Controller
|
||||
'attempts.quiz',
|
||||
'attempts.answers.question',
|
||||
'attempts.answers.option',
|
||||
'jobPosition'
|
||||
'jobPosition',
|
||||
'tenant'
|
||||
]);
|
||||
|
||||
return \Inertia\Inertia::render('Admin/Candidates/Show', [
|
||||
$data = [
|
||||
'candidate' => $candidate,
|
||||
'jobPositions' => \App\Models\JobPosition::all(),
|
||||
'ai_config' => [
|
||||
@@ -99,7 +100,13 @@ class CandidateController extends Controller
|
||||
'gemini' => !empty(env('GEMINI_API_KEY')),
|
||||
], function($v) { return $v; })
|
||||
]
|
||||
]);
|
||||
];
|
||||
|
||||
if (auth()->user()->isSuperAdmin()) {
|
||||
$data['tenants'] = \App\Models\Tenant::orderBy('name')->get();
|
||||
}
|
||||
|
||||
return \Inertia\Inertia::render('Admin/Candidates/Show', $data);
|
||||
}
|
||||
|
||||
public function destroy(Candidate $candidate)
|
||||
@@ -174,6 +181,30 @@ class CandidateController extends Controller
|
||||
return back()->with('success', 'Fiche de poste associée au candidat.');
|
||||
}
|
||||
|
||||
public function updateTenant(Request $request, Candidate $candidate)
|
||||
{
|
||||
if (!auth()->user()->isSuperAdmin()) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$request->validate([
|
||||
'tenant_id' => 'nullable|exists:tenants,id',
|
||||
]);
|
||||
|
||||
$candidate->update([
|
||||
'tenant_id' => $request->tenant_id,
|
||||
]);
|
||||
|
||||
// Also update the associated user's tenant_id if it exists
|
||||
if ($candidate->user) {
|
||||
$candidate->user->update([
|
||||
'tenant_id' => $request->tenant_id,
|
||||
]);
|
||||
}
|
||||
|
||||
return back()->with('success', 'Structure de rattachement mise à jour avec succès.');
|
||||
}
|
||||
|
||||
public function resetPassword(Candidate $candidate)
|
||||
{
|
||||
$password = Str::random(10);
|
||||
|
||||
Reference in New Issue
Block a user