require(); $business->loadMissing(['staff.user', 'serviceCategories.services']); $profile = $request->user()->customerProfiles() ->where('businessId', $business->id) ->first(); $appointments = $profile?->appointments() ->with(['staff.user', 'services.service']) ->where('startAt', '>=', now()->utc()) ->orderBy('startAt') ->get() ?? collect(); $loyaltySummary = $profile ? $loyalty->summary($business, $profile) : null; return view('customer.dashboard', [ 'business' => $business, 'profile' => $profile, 'appointments' => $appointments, 'user' => $request->user(), 'loyaltySummary' => $loyaltySummary, ]); } }