jeudi 26 mars 2020

Laravel Raw query convert into Eloquent ORM format

can anyone help me to convert this query

SELECT 
   employees.username, 
   employees_attendance.employees_id, 
   SUM(employees_attendance.worked_hours) 
FROM 
   employees_attendance 
LEFT JOIN 
   employees ON 
   employees_attendance.employees_id=employees.id 
WHERE 
   timein LIKE '2020-03-26 %' 
GROUP BY 
   employees_attendance.employees_id

into laravel eloquent ORM 2020-03-27 today date.

I wrote like this but syntax voilation error

DB::table('employees_attendance')
          ->leftJoin('employees', 'employees_attendance.employees_id', '=', 'employees.id')
          ->where('employees_attendance.employees_id', '=', 'employees.id')
          ->whereDate('timein', Carbon::today())
          ->select('employees.id as emp_id','employees.username as name')
          ->groupBy('employees_attendance.employees_id')
          ->get();


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire