I am attempting to join three tables, and access the id column on two of them: Jobs - which shows details and job_interviews which holds the job status - accepted or declined.
Specifically, the problem that I am having is that I need to access both id fields: the jobs.id to allow user to see the details and the job_interviews.id to send his accept or decline response.
I set up my join like this:
public static function respondInterviews($jobID){
return DB::table('job_interviews')
->join('jobs', 'jobs.id', '=', 'job_interviews.job_id')
->join('contractors', 'contractors.user_id', '=', 'job_interviews.send_to')
->where('jobs.user_id', '=', $jobID)
->select('jobs.id', 'job_interviews.id as interview_id', 'jobs.title', 'contractors.user_id', 'contractors.contact_name', 'job_interviews.status', 'jobs.created_at', 'jobs.budget', 'jobs.workType','job_interviews.send_to')
->get();
}
I have attempted to set the "id" columns apart by specifying
'job_interviews.id as interview_id',
Then in my page view I iterate through the list of interviews and then call the two id variables:
{{$interview->id}} //which accesses jobs.id and works great
{{$interview->interview_id}} //which is supposed to access job_interviews.id but is not working
The error that laravel is giving me is:
Undefined property: stdClass::$interview_id
How do I access the job_interviews.id column? Thanks in advance for your help.