Hello, I would like to reflect the number of days of an absent worker from his date of absence, either using Carbon or something native in php, I use Laravel, the example is this:
In the DB I consult the absenteeism that said worker has
$ausentismo_anual_dias = $empresa->ausentismo()
->whereYear('fecha_ausente', Carbon::now()->format('Y'))
->get();
In a foreach loop I want to print from its absence date example
foreach($ausentismo_anual_dias as $row){
//Aqui quiero calcular los dias de ausencias
}
Note the days of absence must be calculated per month example This worker is absent from the given date 2018-10-06(Month October) to the end date of the month October 2018-10-31 has 25 days absent, so we go to November 2018- 11-01 to the current date 2018-11-05 has 5 days elapsed in that month All that must be traversed from the cycle
showing it like this:
October: 25 days absent
November: 5 days absent
December should not show since we are not in that month so it should be in 0 days
I hope you can help me with this request.
You must generate the dates that are within the range of absences. You can do something like the following:
to execute:
To show the days for each period you must go through the array generated by the function eg:
I print the outputs of what the function generates:
I managed to print it but it repeats the days in this way