@guianzollin something like this. (only quickly checked)
use Carbon\Carbon;
$start = today();
$end = new Carbon('2023-04-28');
$known= collect(['2023-04-17', '2023-04-22', '2023-05-01']);
// gets the diff in days unless the date is a weekend
$days = $start->diffInDaysFiltered(function(Carbon $date) {
return !($date->isSunday() || $date->isSaturday());
}, $end);
// exclude known dates from calculation between start and end unless they are weekend in which case already allowed for
$exclude = $known->reject(function($date) use($start, $end){
$date = Carbon::parse($date);
if($date->isSunday() || $date->isSaturday()) {
return true;
}
return ($date < $start || $date >$end);
})->count();
$totaldays = $days - $exclude;