Are you able to do the query outside of Eloquent in something like MySQL on Workbench to get it to work how you want? My mind for something this complex gravitates to stitching it together in mysql and looking at it that way.
Feb 26, 2021
3
Level 9
Query not giving expected result in Laravel
In my Laravel-5.8, I have this Query:
From the query above, I want to display all the employees, either the record matches or not. Then, compare the matching records.
The problem now is that whenever there is no matching record for work_location_id for any employee as in:
->join('hr_work_locations AS l', function($join) use ($userCompany)
{
$join->on('l.id', '=', 'e.work_location_id')
->where('l.company_id', '=', $userCompany);
})
it won't add the employee detail into the list of the result. But I want all the employees either there is matching record or not.
How do I do it that whenever there is no matching record for work_location_id, it should just display "Not Specified" for work location instead of omitting the employee record?
Thanks.
Please or to participate in this conversation.