I'm tracking the amount of total time each employee has spent at work from the moment of employment.
I have the entries table (Check in/Check Out), and the time gets calculated after the checkout happens.
However, I have the relevant column for that in integer format, and if FOR EXAMPLE someone enters at 10:53:07 and leaves at 11:18:31, it displays 24 as a result (since there's 24 seconds between 07 and 31). Basically resets back to 0 once it reaches 60.
Picture:
Here's the relevant code I use in the controller for summation:
$employees = Employee::all();
$totals = [];
foreach($employees as $employee)
{
$totals[$employee->id] = $employee->attendances->sum('time_spent_working');
}
I formatted time_spent_working as an integer in the migration itself. What would be the best/cleanest solution here?