@php use App\Models\Branches; use Carbon\Carbon; $selectedBranchId = session('selected_branch'); $branche = Branches::where('id', $selectedBranchId)->first(); $branchSoftware = $branche ? $branche->software : 'Ledgematic'; $expire = false; $leniencyExpire = false; $status = false; if (!empty($selectedBranchId)) { $branch = Branches::find($selectedBranchId); $now = Carbon::parse(now())->format('Y-m-d'); $branchExpireDate = Carbon::parse($branch->expiry_date); $leniency = $branch->leniency; if ($branchExpireDate->addDays($leniency)->lte($now)) { $expire = true; if (!$branch->vouchers->isEmpty()) { foreach ($branch->vouchers as $voucher) { if ($voucher->created_at->gte($branchExpireDate)) { $expire = false; } } } } $status = $branch->status; } @endphp