Kaynağa Gözat

fix reclamations back

Alexander Musikhin 2 ay önce
ebeveyn
işleme
5c3ab0b99f

+ 1 - 2
app/Http/Controllers/ReclamationController.php

@@ -101,8 +101,7 @@ class ReclamationController extends Controller
     {
         $data = $request->validated();
         $reclamation->update($data);
-        $url = $request->previous_url ?? route('reclamations.index', session('gp_reclamations'));
-        return redirect($url);
+        return redirect()->route('reclamations.show', $reclamation->id);
     }
 
     public function uploadPhotoBefore(Request $request, Reclamation $reclamation, FileService $fileService)

+ 3 - 1
resources/views/partials/submit.blade.php

@@ -4,7 +4,9 @@
         @if(isset($delete) && !($deleteDisabled ?? false))
             <a href="#" class="btn btn-sm mb-1 btn-danger delete">{{ $delete['title'] ?? 'Удалить' }}</a>
         @endif
-        <a href="{{ url()->previous() }}" class="btn btn-sm mb-1 btn-outline-secondary">Назад</a>
+
+        <a href="{!! $backurl ?? url()->previous() !!}" class="btn btn-sm mb-1 btn-outline-secondary">Назад</a>
+
     </div>
 </div>
 

+ 7 - 7
resources/views/reclamations/edit.blade.php

@@ -36,7 +36,7 @@
                     @include('partials.select', ['name' => 'reason', 'title' => 'Причина', 'size' => 6, 'value' => $reclamation->reason ?? '', 'options' => ['Вандализм', 'Гарантия', 'Сервисное обслуживание'], 'key_as_val' => true, 'disabled' => !hasRole('admin,manager')])
                     @include('partials.textarea', ['name' => 'guarantee', 'title' => 'Гарантии', 'size' => 6, 'value' => $reclamation->guarantee ?? '', 'disabled' => !hasRole('admin,manager')])
                     @include('partials.textarea', ['name' => 'whats_done', 'title' => 'Что сделано', 'size' => 6, 'value' => $reclamation->whats_done ?? '', 'disabled' => !hasRole('admin,manager')])
-                    @include('partials.submit', ['name' => 'Сохранить', 'offset' => 5, 'disabled' => !hasRole('admin,manager')])
+                    @include('partials.submit', ['name' => 'Сохранить', 'offset' => 5, 'disabled' => !hasRole('admin,manager'), 'backurl' => route('reclamations.index', session('gp_reclamations'))])
                 </form>
             </div>
             <div class="col-xl-7 ">
@@ -195,13 +195,13 @@
                                     <i class="bi bi-x-circle-fill fs-6 text-danger cursor-pointer ms-2"
                                        onclick="if(confirm('Удалить?')) $('#act-{{ $act->id }}').submit()"
                                        title="Удалить"></i>
+                                    <form action="{{ route('reclamations.delete-act', [$reclamation, $act]) }}"
+                                          method="POST"
+                                          id="act-{{ $act->id }}" class="visually-hidden">
+                                        @csrf
+                                        @method('DELETE')
+                                    </form>
                                 @endif
-                                <form action="{{ route('reclamations.delete-act', [$reclamation, $act]) }}"
-                                      method="POST"
-                                      id="act-{{ $act->id }}" class="visually-hidden">
-                                    @csrf
-                                    @method('DELETE')
-                                </form>
                             </div>
                         @endforeach
                     </div>