I have a two table named applicants
and jobs
. I am using Laravel 5.2.
jobs table:
id | job_tittle | email |...
-----------------------------
1 | Engineer | info@mail.com |...
applicants table:
id | job_id | name |...
-----------------------------
1 | 1 | john |...
Now i want when anyone submit the application form against a job then job_id is auto inserted in the applicants
table.
I have tried so far ApplicantController:
$jobAll = Job::all();
$jobId = Job::find($jobAll->first()->id);
//$jobId = $jobAll->first()->id;
DB::table('applicants')->insert([
'job_id' => $jobId,
]);
But its not working.Could anyone tell me how can i do that? Thanks in advance.