php - Laravel: get table of month's dates via Carbon
one text
Solution:
That's definitely possibly. Since it sounds pretty interactive to me, I would probably combine it with a JS framework like Vue.js
. The benefit of using Vue in this case, is that you won't visibly have to submit a form (meaning that the page will refresh) when selecting a work shift: you can easily do this under the hood by sending an Ajax
call. It is however not necessary to accomplish what you want.
Using Carbon
, you can get the days in the current month by doing:
$period = Carbon\CarbonPeriod::create(Carbon\Carbon::now()->startOfMonth(), Carbon\Carbon::now()->endOfMonth());
foreach($period as $date)
{
$dates[] = $date->format('d-m-Y');
}
Source