Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

noblemfd's avatar

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

0 likes
0 replies

Please or to participate in this conversation.