May be this will work for you:
DB::table('emp')
->select(DB::raw("MIN(`time`) AS `time_in`, MAX(`time`) AS `time_out`"))
->where('date', '2017-06-13')
->get();
Output:
{
time_in: "19:38:33",
time_out: "22:14:10"
}
Try Below Code :
$attendancehours = DB::select(
DB::RAW('TIMESTAMPDIFF(HOUR,CONCAT(in_date," ",in_time),CONCAT(out_date," ",out_time)'))->
table('staff_attendances')->
whereBetween('in_date', array($date1, $date2))->
where('id', $sID)
->get();
You can order your table by the date and time columns and then use Eloquent to take ->first() and ->last() using those methods.
$collection = BiometricsAttendance::where('emp_id', $emp)->whereBetween('date', [$start, $end])->groupBy('date')->orderBy('time', 'asc');
$timein = $collection->first();
$timeout = $collection->last();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.