i have a table name merge_jobs and another table name employer_jobs.
merge_jobs has a column called employer_id which matches with user_id column in employer job
merge_job table also have a column called user_id
So I want to get rows where the user_id in merge_jobs matches the authenticated user where employer_id of the selected rows matches the user_id of the employer_jobs
I tried to use left join but did not work
My code
$jobs = DB::table('job_mergings')
->leftJoin('employer_jobs', function($join)
{
$join->on('job_mergings.employer_id', '=', 'employer_jobs.user_id');
})
->where('job_mergings.user_id', '=', Auth::user()->id)
->get();
2
Answers
I think there’s just a mistake in your query and you should correct it like this:
you can get the authenticated user id from the request like this