Sep 29, 2020
0
Level 9
Getting resumption date from commencement date and days
Initially I have this code that that gets leave days (days) from difference between commencement date, resumption date, holiday and weekend:
$commencementDate = Carbon::parse($request->commencement_date);
$resumptionDate = Carbon::parse($request->resumption_date);
$holidays = DB::table('hr_holiday_dates')->select('holiday_date')->whereYear('created_at', '=', date('Y'))->get()->pluck('holiday_date')->toArray();
$days = $commencementDate->diffInDaysFiltered(function (Carbon $date) use ($holidays) {
return $date->isWeekday() && !in_array($date, $holidays);
}, $resumptionDate);
But now this have changed. The user is just to enter commencement date and days.
How do I change my initial code above to get resumption date from commencement date, days, holidays and weekends?
Thanks
Please or to participate in this conversation.