@php $business_id = session()->get('user.business_id') ?: 1; // 1. LIVE DATABASE QUERY: Fetch services from products & variations in Ultimate POS $products = \App\Product::with(['variations', 'category']) ->where('business_id', $business_id) ->where('is_inactive', 0) ->get(); $services = $products->map(function($p) { $price = 0; $variation_id = null; if ($p->variations && $p->variations->first()) { $price = $p->variations->first()->sell_price_inc_tax; $variation_id = $p->variations->first()->id; } $duration = $p->salon_duration_minutes ?: ($p->preparation_time_in_minutes ?: 45); $chairType = $p->salon_required_chair_type ?: 'Styling Chair'; return (object) [ 'id' => $p->id, 'variation_id' => $variation_id, 'name' => $p->name, 'sku' => $p->sku, 'duration_minutes' => $duration, 'price' => $price ?: 2500, 'requires_chair_type' => $chairType, 'category_name' => $p->category ? $p->category->name : 'Services' ]; }); // 2. LIVE DATABASE QUERY: Fetch active stylists / service staff (users) $stylists = \App\User::where('business_id', $business_id) ->where('status', 'active') ->get() ->map(function($u) { return (object) [ 'id' => $u->id, 'name' => trim($u->first_name . ' ' . $u->last_name), 'role' => $u->role_name ?? 'Stylist' ]; }); if ($stylists->isEmpty()) { $stylists = collect([ (object)['id' => 1, 'name' => 'Amelda Fernando', 'role' => 'Lead Stylist'], (object)['id' => 2, 'name' => 'Kasun Jayawardena', 'role' => 'Senior Hair Designer'], (object)['id' => 3, 'name' => 'Niluka Perera', 'role' => 'Bridal Specialist'] ]); } // 3. LIVE DATABASE QUERY: Fetch salon chairs from salon_chairs table $chairs = \Modules\SalonBooking\Entities\SalonChair::where('business_id', $business_id)->get(); if ($chairs->isEmpty()) { $defaultChairs = [ ['business_id' => $business_id, 'name' => 'Chair #1 (VIP Styling Station)', 'type' => 'Styling Chair', 'status' => 'available'], ['business_id' => $business_id, 'name' => 'Chair #2 (Main Floor Styling)', 'type' => 'Styling Chair', 'status' => 'available'], ['business_id' => $business_id, 'name' => 'Chair #3 (Hair & Color Station)', 'type' => 'Styling Chair', 'status' => 'available'], ['business_id' => $business_id, 'name' => 'Chair #4 (Makeup Suite)', 'type' => 'Makeup / Beauty Chair', 'status' => 'available'], ['business_id' => $business_id, 'name' => 'Suite #1 (Luxury Bridal Room)', 'type' => 'Bridal Suite', 'status' => 'available'], ['business_id' => $business_id, 'name' => 'Bed #1 (Facial & Skin Care Bed)', 'type' => 'Facial / Spa Bed', 'status' => 'available'] ]; foreach ($defaultChairs as $dc) { \Modules\SalonBooking\Entities\SalonChair::create($dc); } $chairs = \Modules\SalonBooking\Entities\SalonChair::where('business_id', $business_id)->get(); } // Existing customers for fast search and duplicate prevention $customers = \App\Contact::where('business_id', $business_id) ->whereIn('type', ['customer', 'both']) ->orderBy('name') ->limit(1000) ->get(); // 4. LIVE DATABASE QUERY: Salon / Business Name $business = \App\Business::find($business_id); $salonName = $business ? $business->name : 'Amelda Hair & Makeup'; @endphp