Вы можете сослаться на запрос ниже, который написан в laravel -
DB::table('as_tbl_employee_master AS emp') ->select('emp.id','emp.employee_id',
'emp.sys_emp_id','emp.english_name','dept.department','pos.position_name',
'att.CHECK_IN_TIME','att.CHECK_OUT_TIME')
->join('as_tbl_department AS dept','emp.department_id','=', 'dept.id')
->join('as_tbl_employee_position AS pos', 'emp.position_id', '=', 'pos.id')
->join('as_tbl_emp_attendance_daily_log AS att', 'att.EMPLOYEE_ID', '=', 'emp.employee_id')
->where('emp.employee_id', $sys_emp_id)
->orderby('att.CHECK_IN_TIME', 'DESC')
->get();
или
Альтернатива использует тот же запрос, который вы написали, но с DB
помощником, например -
Добавьте use DB;
в свой контроллер.
DB::select('select * from
(SELECT emp.employee_id,emp.english_name, emp.reports_to,
dept.department, pos.position_name,
att.CHECK_IN_TIME,att.CHECK_OUT_TIME
FROM as_tbl_employee_master emp
inner join as_tbl_department dept on emp.department_id = dept.id
inner join as_tbl_employee_position pos on emp.position_id = pos.id
inner join as_tbl_emp_attendance_daily_log att on att.EMPLOYEE_ID = emp.employee_id) as TAB
where TAB.reports_to = 18');
Кроме того, использование sql инъекций - лучшая практика.
DB::select('select * from
(SELECT emp.employee_id,emp.english_name, emp.reports_to,
dept.department, pos.position_name,
att.CHECK_IN_TIME,att.CHECK_OUT_TIME
FROM as_tbl_employee_master emp
inner join as_tbl_department dept on emp.department_id = dept.id
inner join as_tbl_employee_position pos on emp.position_id = pos.id
inner join as_tbl_emp_attendance_daily_log att on att.EMPLOYEE_ID = emp.employee_id) as TAB
where TAB.reports_to = ?', [18]);
Надеюсь, это поможет вам.