Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

alnouirah's avatar

The right way to delete record from pivot table ?

I have three tables :

candidates : 
id (int)
name (varchar)

and

available_jobs: 
id (int)
title (varchar)

and the pivot table where the candidate can apply for job

job_applications: 
id (int)
candidate_id (int) foreign key reference candidate(id),
available_jobs_id (int) oreign key reference available_jobs(id),

this is my function for deleting candidates :

public function destroy (Candidate $candidate){
	$candidate->delete();
}

as will as deleting an available_job :

public function destroy (AvailableJob $job){
	$job->delete();
}

My question is how to type hint and delete the applications! I know that I can delete the application using ( where close ) by specifying the candidate_id and the available_jobs_id but I am asking if there is another way like type-hinting or something like that!

0 likes
2 replies
alnouirah's avatar

I really don't know how I missed reading this part of the Documentation. Thank you :)

Please or to participate in this conversation.