Enhance candidates management: add city field, drag-and-drop ranking persistence, AI analysis popover, and CV preview

This commit is contained in:
mrKamoo
2026-04-22 15:26:15 +02:00
parent 174f229b5d
commit 6f00da6d10
13 changed files with 480 additions and 116 deletions

View File

@@ -39,6 +39,36 @@ class CandidateController extends Controller
]);
}
public function selectedCandidates()
{
$candidates = Candidate::with(['user', 'jobPosition', 'attempts.quiz', 'documents'])
->where('is_selected', true)
->orderBy('sort_order')
->get()
->map(function($candidate) {
$candidate->weighted_score = $candidate->weighted_score;
return $candidate;
});
return \Inertia\Inertia::render('Admin/Candidates/Selected', [
'candidates' => $candidates
]);
}
public function updateOrder(Request $request)
{
$request->validate([
'ids' => 'required|array',
'ids.*' => 'exists:candidates,id',
]);
foreach ($request->ids as $index => $id) {
Candidate::where('id', $id)->update(['sort_order' => $index]);
}
return back()->with('success', 'Classement enregistré.');
}
public function store(Request $request)
{
$request->validate([
@@ -46,6 +76,7 @@ class CandidateController extends Controller
'email' => 'required|string|email|max:255|unique:users',
'phone' => 'nullable|string|max:20',
'linkedin_url' => 'nullable|url|max:255',
'city' => 'nullable|string|max:255',
'cv' => 'nullable|mimes:pdf|max:5120',
'cover_letter' => 'nullable|mimes:pdf|max:5120',
'tenant_id' => 'nullable|exists:tenants,id',
@@ -65,6 +96,7 @@ class CandidateController extends Controller
$candidate = $user->candidate()->create([
'phone' => $request->phone,
'linkedin_url' => $request->linkedin_url,
'city' => $request->city,
'status' => 'en_attente',
'tenant_id' => auth()->user()->isSuperAdmin() ? $request->tenant_id : auth()->user()->tenant_id,
'job_position_id' => $request->job_position_id,
@@ -143,6 +175,7 @@ class CandidateController extends Controller
'email' => 'nullable|string|email|max:255|unique:users,email,' . $candidate->user_id,
'phone' => 'nullable|string|max:255',
'linkedin_url' => 'nullable|url|max:255',
'city' => 'nullable|string|max:255',
]);
// Update User info if name or email present
@@ -151,7 +184,7 @@ class CandidateController extends Controller
}
// Update Candidate info
$candidate->update($request->only(['phone', 'linkedin_url']));
$candidate->update($request->only(['phone', 'linkedin_url', 'city']));
if ($request->hasFile('cv')) {
$this->replaceDocument($candidate, $request->file('cv'), 'cv');

View File

@@ -11,7 +11,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Traits\BelongsToTenant;
#[Fillable(['user_id', 'job_position_id', 'phone', 'linkedin_url', 'status', 'is_selected', 'notes', 'cv_score', 'motivation_score', 'interview_score', 'interview_details', 'ai_analysis', 'tenant_id'])]
#[Fillable(['user_id', 'job_position_id', 'phone', 'linkedin_url', 'city', 'status', 'is_selected', 'sort_order', 'notes', 'cv_score', 'motivation_score', 'interview_score', 'interview_details', 'ai_analysis', 'tenant_id'])]
class Candidate extends Model
{
use HasFactory, BelongsToTenant;