form.blade.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. {{-- Вьюха: форма создания/редактирования услуги --}}
  2. @extends('admin.layout')
  3. @section('title', $service->exists ? 'Редактировать услугу' : 'Новая услуга')
  4. @section('content_header')
  5. <div class="d-flex justify-content-between align-items-center">
  6. <h1 class="m-0">{{ $service->exists ? 'Услуга: ' . $service->title : 'Новая услуга' }}</h1>
  7. <a href="{{ route('admin.services.index') }}" class="btn btn-default btn-sm">
  8. <i class="fas fa-arrow-left"></i> Назад
  9. </a>
  10. </div>
  11. @stop
  12. @section('breadcrumb')
  13. <li class="breadcrumb-item"><a href="{{ route('admin.dashboard') }}">Главная</a></li>
  14. <li class="breadcrumb-item"><a href="{{ route('admin.services.index') }}">Услуги</a></li>
  15. <li class="breadcrumb-item active">{{ $service->exists ? 'Редактировать' : 'Новая' }}</li>
  16. @stop
  17. @section('content')
  18. @if($service->exists)
  19. <form action="{{ route('admin.services.update', $service) }}" method="POST">
  20. @method('PUT')
  21. @else
  22. <form action="{{ route('admin.services.store') }}" method="POST">
  23. @endif
  24. @csrf
  25. <div class="row">
  26. {{-- Левая колонка --}}
  27. <div class="col-md-8">
  28. <div class="card card-primary card-outline">
  29. <div class="card-header"><h3 class="card-title">Основное</h3></div>
  30. <div class="card-body">
  31. <div class="form-group">
  32. <label>Название услуги <span class="text-danger">*</span></label>
  33. <input type="text" name="title"
  34. class="form-control @error('title') is-invalid @enderror"
  35. value="{{ old('title', $service->title) }}" required>
  36. @error('title')<div class="invalid-feedback">{{ $message }}</div>@enderror
  37. </div>
  38. @if($service->exists)
  39. <div class="form-group">
  40. <label>Slug (URL)</label>
  41. <input type="text" class="form-control" value="{{ $service->slug }}" readonly>
  42. <small class="text-muted">
  43. Публичный адрес:
  44. <a href="{{ route('services.show', $service->slug) }}" target="_blank">
  45. /services/{{ $service->slug }}
  46. </a>
  47. </small>
  48. </div>
  49. @endif
  50. <div class="form-group">
  51. <label>Иконка (emoji)</label>
  52. <input type="text" name="icon" maxlength="10"
  53. class="form-control form-control-sm" style="max-width:80px;font-size:20px"
  54. value="{{ old('icon', $service->icon) }}"
  55. placeholder="✈️">
  56. <small class="text-muted">Одна emoji — отображается в блоке услуг</small>
  57. </div>
  58. <div class="form-group">
  59. <label>Краткое описание <small class="text-muted">(для списка)</small></label>
  60. <textarea name="excerpt" class="form-control @error('excerpt') is-invalid @enderror"
  61. rows="2" maxlength="500"
  62. placeholder="1–2 предложения для карточки на странице услуг">{{ old('excerpt', $service->excerpt) }}</textarea>
  63. @error('excerpt')<div class="invalid-feedback">{{ $message }}</div>@enderror
  64. </div>
  65. @php
  66. $countriesSection = \App\Models\DictSection::where('code','countries')->first();
  67. $tagsSection = \App\Models\DictSection::where('code','service_tags')->first();
  68. $allCountries = $countriesSection
  69. ? \App\Models\DictValue::where('section_id',$countriesSection->id)->orderBy('sort_order')->get()
  70. : collect();
  71. $allServiceTags = $tagsSection
  72. ? \App\Models\DictValue::where('section_id',$tagsSection->id)->orderBy('sort_order')->get()
  73. : collect();
  74. $selectedTagIds = array_map('intval', old('tags', $service->tags ?? []));
  75. @endphp
  76. <div class="form-group mb-0">
  77. <label class="font-weight-bold">Теги</label>
  78. <small class="text-muted d-block mb-2">Выбирайте из справочника — страны и функциональные метки</small>
  79. @if($allCountries->isNotEmpty())
  80. <div class="mb-2">
  81. <div class="small text-muted font-weight-bold mb-1 text-uppercase" style="letter-spacing:.06em">Страны</div>
  82. <div class="border rounded p-2" style="background:#f8f9fa">
  83. <div class="row">
  84. @foreach($allCountries as $country)
  85. <div class="col-6 col-md-4">
  86. <div class="form-check">
  87. <input class="form-check-input" type="checkbox"
  88. name="tags[]"
  89. value="{{ $country->id }}"
  90. id="tag-{{ $country->id }}"
  91. @checked(in_array($country->id, $selectedTagIds))>
  92. <label class="form-check-label" for="tag-{{ $country->id }}">
  93. {{ $country->flag }} {{ $country->value }}
  94. </label>
  95. </div>
  96. </div>
  97. @endforeach
  98. </div>
  99. </div>
  100. </div>
  101. @endif
  102. @if($allServiceTags->isNotEmpty())
  103. <div>
  104. <div class="small text-muted font-weight-bold mb-1 text-uppercase" style="letter-spacing:.06em">Метки услуг</div>
  105. <div class="border rounded p-2" style="background:#f8f9fa">
  106. <div class="row">
  107. @foreach($allServiceTags as $tag)
  108. <div class="col-6 col-md-4">
  109. <div class="form-check">
  110. <input class="form-check-input" type="checkbox"
  111. name="tags[]"
  112. value="{{ $tag->id }}"
  113. id="tag-{{ $tag->id }}"
  114. @checked(in_array($tag->id, $selectedTagIds))>
  115. <label class="form-check-label" for="tag-{{ $tag->id }}">
  116. {{ $tag->value }}
  117. </label>
  118. </div>
  119. </div>
  120. @endforeach
  121. </div>
  122. </div>
  123. </div>
  124. @endif
  125. </div>
  126. </div>
  127. </div>
  128. <div class="card card-secondary card-outline">
  129. <div class="card-header"><h3 class="card-title">Полное описание</h3></div>
  130. <div class="card-body">
  131. <div class="form-group mb-0">
  132. <label>HTML-контент детальной страницы</label>
  133. <textarea name="description"
  134. class="form-control @error('description') is-invalid @enderror"
  135. rows="12"
  136. placeholder="Полное описание услуги — HTML-теги допустимы">{{ old('description', $service->description) }}</textarea>
  137. <small class="text-muted">Отображается на детальной странице /services/{{ $service->slug ?: '{slug}' }}</small>
  138. @error('description')<div class="invalid-feedback">{{ $message }}</div>@enderror
  139. </div>
  140. </div>
  141. </div>
  142. </div>
  143. {{-- Правая колонка --}}
  144. <div class="col-md-4">
  145. <div class="card card-secondary card-outline">
  146. <div class="card-header"><h3 class="card-title">Публикация</h3></div>
  147. <div class="card-body">
  148. <div class="custom-control custom-switch mb-3">
  149. <input type="checkbox" class="custom-control-input" id="is_active"
  150. name="is_active" value="1"
  151. {{ old('is_active', $service->is_active ?? true) ? 'checked' : '' }}>
  152. <label class="custom-control-label" for="is_active">Услуга активна</label>
  153. </div>
  154. <div class="form-group mb-0">
  155. <label>Порядок сортировки</label>
  156. <input type="number" name="sort_order" min="0"
  157. class="form-control form-control-sm"
  158. style="max-width:100px"
  159. value="{{ old('sort_order', $service->sort_order ?? 0) }}">
  160. <small class="text-muted">Чем меньше — тем выше в списке</small>
  161. </div>
  162. </div>
  163. <div class="card-footer">
  164. <button type="submit" class="btn btn-primary btn-block">
  165. <i class="fas fa-save"></i> Сохранить
  166. </button>
  167. <a href="{{ route('admin.services.index') }}" class="btn btn-secondary btn-block mt-1">
  168. Отмена
  169. </a>
  170. </div>
  171. </div>
  172. </div>
  173. </div>
  174. </form>
  175. @stop