Level 75
Just curious if that is working why not just use as is with the db facade or getPdo (). Both are still part of laravel.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have this MYSQL Query that is working fine
SELECT e.id, e.employee_code, concat(e.first_name,' ',e.last_name) Fullname, e.email, e.department_id,
CASE
WHEN a.line_manager_mid_year_approved = 0 THEN "DRAFT"
WHEN a.line_manager_mid_year_approved = 1 THEN "AWAITING APPROVAL"
WHEN a.line_manager_mid_year_approved = 2 THEN "NOT APPROVED"
WHEN a.line_manager_mid_year_approved = 3 THEN "APPROVED"
ELSE "NOT STARTED"
END AS line_manager_mid_year_approved,
e.grade_level_name, e.work_location_id, e.line_manager_id
FROM hr_employees e
LEFT JOIN
(SELECT * FROM appraisal_goals GROUP BY employee_id) a
ON a.employee_id = e.id
WHERE e.company_id = 1
AND a.is_active = 1
AND e.hr_status = 0
AND e.validation_status = 'VALID'
AND e.employee_type_code NOT IN (4,5)
ORDER BY e.employee_code;
How do I write it as Laravel Query?
Thanks
Yes you can write a normal pdo query here is example https://laracasts.com/discuss/channels/laravel/sql-native-to-query-builder
Or do you specifically want an eloquent query.
Please or to participate in this conversation.