How to make a period by days of the week. Instead every 3rd day from example, to be every monday, friday for that period ?
$period = CarbonPeriod::create(Carbon::now(), '3 days', Carbon::now()->addMonths(3));
// In an ideal world it would be like this :)
$period = CarbonPeriod::create(Carbon::now(), [Carbon::MONDAY, Carbon::FRIDAY], Carbon::now()->addMonths(3));
If you want every Monday through Friday, you can use what @michaloravec wrote, if you want just the Mondays and Fridays you can check for isMonday() and isFriday() in your filter.
What do you mean doesn't work? I just ran it when I posted it. 🤔 If you want proof here are some screenshots of the code and output, ignore the phpcs warnings.
@thinkverse This Carbon function is little tricky. I don't know how to pass the certain days off the week from the outside.
I dont want hard-coded days of week. Is there any array that could be inserted into the filter?
I know that my example like this is impossible, but I can't handle the carbon function.