I want to compute all the users time in and time out then if the time in and time out is null i skip that in computation to avoid error and sum all total of hours
Nov 8, 2022
2
Level 1
Compute the total TIME IN and TIME OUT of HOURS
My code only compute the total hours of last array of data and also didn't compute the null value
$day=Tms::where('users_id',$request->user)->whereBetween('day', [$request->first, $request->last])->get();
$users=Tms::where('users_id', $request->user)->take(1)->get();
foreach($day as $hour){
$timeIn=Carbon::createFromFormat('g:i A', $hour->time_in);
$timeOut=Carbon::createFromFormat('g:i A', $hour->time_out);
$total_minutes=$timeIn->diffInMinutes($timeOut);
// dd($hour->time_in);
}
$total=$total_minutes/60;
return view('home.admin.tms.calculated_hours')->with(['day'=>$day,'totalHR'=>$total, 'user'=>$users]);
My problem is how to fix this that compute all the time in and time out total hours of WhereBetween date
Please or to participate in this conversation.