{{-- resources/views/admin/services/form.blade.php --}} @extends('layouts.master') @section('title', isset($service) ? 'تعديل خدمة' : 'إضافة خدمة') @section('pages') {{ __('dashboard.home') }} @endsection @section('css') @endsection @section('content') @php $isEdit = isset($service); $action = $isEdit ? route('services.update', $service) : route('services.store'); $method = $isEdit ? 'PUT' : 'POST'; $formatTime = function ($t) { if (!$t) { return ''; } $p = explode(':', $t); return sprintf('%02d:%02d', (int) ($p[0] ?? 0), (int) ($p[1] ?? 0)); }; // كود الخدمة للعرض فقط (التوليد الفعلي في السيرفر) $serviceCodeDisplay = $isEdit ? $service->service_code ?? '-' : $suggestedServiceCode ?? '1001'; // القيم القديمة/الافتراضية $oldSettings = old('settings', $isEdit ? $service->settings ?? [] : []); $daysAll = [ 'sat' => 'السبت', 'sun' => 'الأحد', 'mon' => 'الإثنين', 'tue' => 'الثلاثاء', 'wed' => 'الأربعاء', 'thu' => 'الخميس', 'fri' => 'الجمعة', ]; $daysSelected = old( 'days', $isEdit ? $service->days ?? ($oldSettings['days']['values'] ?? []) : ['sat', 'sun', 'mon', 'tue', 'wed', 'thu'], // افتراضيًا الكل عدا الجمعة ); // فروع مقدِّمة/بائعة بالخانات المتكررة $providedOld = old('provided_branches', $isEdit ? $service->providedBranches->pluck('id')->all() : []); $soldOld = old('sold_branches', $isEdit ? $service->soldBranches->pluck('id')->all() : []); if (empty($providedOld)) { $providedOld = [null]; } if (empty($soldOld)) { $soldOld = [null]; } @endphp @if ($errors->any())