{{-- 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())
@endif
@csrf @if ($isEdit) @method('PUT') @endif {{-- عنوان + أزرار --}}
{{ __('dashboard.back') }}
{{-- Tabs --}}
{{-- تبويب: البيانات الأساسية --}}
البيانات الأساسية
@unless ($isEdit) @endunless
@php $activeOld = old('active', $isEdit? (int)$service->active : 1); @endphp
@php $du = old('duration_unit', $isEdit? $service->duration_unit : 'days'); @endphp
{{-- تبويب: أيام الخدمة (خارج الإعدادات) --}}
{{-- تبويب: فروع الخدمة (مُقدِّمة/بائعة) --}}
@php // تأكيد وجود المصفوفتين (في حال مش متعرفين فوق) $providedOld = $providedOld ?? old('provided_branches', isset($service) ? $service->providedBranches->pluck('id')->all() : []); $soldOld = $soldOld ?? old('sold_branches', isset($service) ? $service->soldBranches->pluck('id')->all() : []); $locale = app()->getLocale(); @endphp {{-- الفروع المُقدِّمة --}}
الفروع المُقدِّمة للخدمة
0 محدد
@foreach ($branches as $b) @php $bName = method_exists($b,'getTranslation') ? $b->getTranslation('name',$locale) : $b->name; @endphp
@endforeach
{{-- الفروع البائعة --}}
الفروع بائعة الخدمة
0 محدد
@foreach ($branches as $b) @php $bName = method_exists($b,'getTranslation') ? $b->getTranslation('name',$locale) : $b->name; @endphp
@endforeach
{{-- تبويب: إعدادات الخدمة --}}
إعدادات الخدمة (اختيارية)
{{-- إيقاف --}} @php $pause = $oldSettings['pause'] ?? []; @endphp
@php $pdu = old('settings.pause.max_duration_unit', $pause['max_duration_unit'] ?? 'days'); @endphp
{{-- تنازل --}} @php $tr = $oldSettings['transfer'] ?? []; @endphp
@php $tdu = old('settings.transfer.min_duration_unit', $tr['min_duration_unit'] ?? 'days'); @endphp
{{-- تجديد --}} @php $rn = $oldSettings['renew'] ?? []; @endphp
@php $re = old('settings.renew.extra_duration_unit', $rn['extra_duration_unit'] ?? 'days'); @endphp
@php $rmx = old('settings.renew.max_duration_unit', $rn['max_duration_unit'] ?? 'days'); @endphp
{{-- استرجاع --}} @php $rf = $oldSettings['refund'] ?? []; @endphp
@php $rmth = old('settings.refund.method', $rf['method'] ?? 'money'); @endphp
أيام تقديم الخدمة
@foreach ($daysAll as $k => $label)
@endforeach
{{-- /tab-content --}}
@endsection @section('js') @endsection