AI Analysis: JobPosition infrastructure and candidate association
This commit is contained in:
@@ -75,11 +75,13 @@ class CandidateController extends Controller
|
||||
'documents',
|
||||
'attempts.quiz',
|
||||
'attempts.answers.question',
|
||||
'attempts.answers.option'
|
||||
'attempts.answers.option',
|
||||
'jobPosition'
|
||||
]);
|
||||
|
||||
return \Inertia\Inertia::render('Admin/Candidates/Show', [
|
||||
'candidate' => $candidate
|
||||
'candidate' => $candidate,
|
||||
'jobPositions' => \App\Models\JobPosition::all()
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -142,6 +144,19 @@ class CandidateController extends Controller
|
||||
return back()->with('success', 'Notes mises à jour avec succès.');
|
||||
}
|
||||
|
||||
public function updatePosition(Request $request, Candidate $candidate)
|
||||
{
|
||||
$request->validate([
|
||||
'job_position_id' => 'nullable|exists:job_positions,id',
|
||||
]);
|
||||
|
||||
$candidate->update([
|
||||
'job_position_id' => $request->job_position_id,
|
||||
]);
|
||||
|
||||
return back()->with('success', 'Fiche de poste associée au candidat.');
|
||||
}
|
||||
|
||||
public function resetPassword(Candidate $candidate)
|
||||
{
|
||||
$password = Str::random(10);
|
||||
|
||||
73
app/Http/Controllers/JobPositionController.php
Normal file
73
app/Http/Controllers/JobPositionController.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\JobPosition;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class JobPositionController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$this->authorizeAdmin();
|
||||
|
||||
return Inertia::render('Admin/JobPositions/Index', [
|
||||
'jobPositions' => JobPosition::all()
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$this->authorizeAdmin();
|
||||
|
||||
$request->validate([
|
||||
'title' => 'required|string|max:255',
|
||||
'description' => 'required|string',
|
||||
'requirements' => 'nullable|array',
|
||||
]);
|
||||
|
||||
JobPosition::create([
|
||||
'title' => $request->title,
|
||||
'description' => $request->description,
|
||||
'requirements' => $request->requirements,
|
||||
]);
|
||||
|
||||
return back()->with('success', 'Fiche de poste créée avec succès.');
|
||||
}
|
||||
|
||||
public function update(Request $request, JobPosition $jobPosition)
|
||||
{
|
||||
$this->authorizeAdmin();
|
||||
|
||||
$request->validate([
|
||||
'title' => 'required|string|max:255',
|
||||
'description' => 'required|string',
|
||||
'requirements' => 'nullable|array',
|
||||
]);
|
||||
|
||||
$jobPosition->update([
|
||||
'title' => $request->title,
|
||||
'description' => $request->description,
|
||||
'requirements' => $request->requirements,
|
||||
]);
|
||||
|
||||
return back()->with('success', 'Fiche de poste mise à jour.');
|
||||
}
|
||||
|
||||
public function destroy(JobPosition $jobPosition)
|
||||
{
|
||||
$this->authorizeAdmin();
|
||||
|
||||
$jobPosition->delete();
|
||||
|
||||
return back()->with('success', 'Fiche de poste supprimée.');
|
||||
}
|
||||
|
||||
private function authorizeAdmin()
|
||||
{
|
||||
if (!auth()->user()->isAdmin()) {
|
||||
abort(403);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user