|
@@ -54,6 +54,7 @@ class ReclamationController extends Controller
|
|
|
|
|
|
|
|
public function index(Request $request)
|
|
public function index(Request $request)
|
|
|
{
|
|
{
|
|
|
|
|
+ session(['gp_reclamations' => $request->all()]);
|
|
|
$model = new Reclamation();
|
|
$model = new Reclamation();
|
|
|
// fill filters
|
|
// fill filters
|
|
|
$this->createFilters($model, 'user_id', 'status_id');
|
|
$this->createFilters($model, 'user_id', 'status_id');
|
|
@@ -82,12 +83,13 @@ class ReclamationController extends Controller
|
|
|
]);
|
|
]);
|
|
|
$skus = $request->validated('skus');
|
|
$skus = $request->validated('skus');
|
|
|
$reclamation->skus()->attach($skus);
|
|
$reclamation->skus()->attach($skus);
|
|
|
- return redirect()->route('reclamations.show', $reclamation);
|
|
|
|
|
|
|
+ return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => url()->previous()]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function show(Reclamation $reclamation)
|
|
|
|
|
|
|
+ public function show(Request $request, Reclamation $reclamation)
|
|
|
{
|
|
{
|
|
|
$this->data['reclamation'] = $reclamation;
|
|
$this->data['reclamation'] = $reclamation;
|
|
|
|
|
+ $this->data['previous_url'] = $request->get('previous_url');
|
|
|
return view('reclamations.edit', $this->data);
|
|
return view('reclamations.edit', $this->data);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -95,7 +97,8 @@ class ReclamationController extends Controller
|
|
|
{
|
|
{
|
|
|
$data = $request->validated();
|
|
$data = $request->validated();
|
|
|
$reclamation->update($data);
|
|
$reclamation->update($data);
|
|
|
- return redirect()->route('reclamations.show', $reclamation);
|
|
|
|
|
|
|
+ $url = $request->previous_url ?? route('reclamations.index', session('gp_reclamations'));
|
|
|
|
|
+ return redirect($url);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function uploadPhotoBefore(Request $request, Reclamation $reclamation, FileService $fileService)
|
|
public function uploadPhotoBefore(Request $request, Reclamation $reclamation, FileService $fileService)
|
|
@@ -109,7 +112,7 @@ class ReclamationController extends Controller
|
|
|
}
|
|
}
|
|
|
$reclamation->photos_before()->syncWithoutDetaching($f);
|
|
$reclamation->photos_before()->syncWithoutDetaching($f);
|
|
|
|
|
|
|
|
- return redirect()->route('reclamations.show', $reclamation);
|
|
|
|
|
|
|
+ return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function uploadPhotoAfter(Request $request, Reclamation $reclamation, FileService $fileService)
|
|
public function uploadPhotoAfter(Request $request, Reclamation $reclamation, FileService $fileService)
|
|
@@ -123,23 +126,23 @@ class ReclamationController extends Controller
|
|
|
}
|
|
}
|
|
|
$reclamation->photos_after()->syncWithoutDetaching($f);
|
|
$reclamation->photos_after()->syncWithoutDetaching($f);
|
|
|
|
|
|
|
|
- return redirect()->route('reclamations.show', $reclamation);
|
|
|
|
|
|
|
+ return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function deletePhotoBefore(Reclamation $reclamation, File $file, FileService $fileService)
|
|
|
|
|
|
|
+ public function deletePhotoBefore(Request $request, Reclamation $reclamation, File $file, FileService $fileService)
|
|
|
{
|
|
{
|
|
|
$reclamation->photos_before()->detach($file);
|
|
$reclamation->photos_before()->detach($file);
|
|
|
Storage::disk('public')->delete($file->path);
|
|
Storage::disk('public')->delete($file->path);
|
|
|
$file->delete();
|
|
$file->delete();
|
|
|
- return redirect()->route('reclamations.show', $reclamation);
|
|
|
|
|
|
|
+ return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function deletePhotoAfter(Reclamation $reclamation, File $file, FileService $fileService)
|
|
|
|
|
|
|
+ public function deletePhotoAfter(Request $request, Reclamation $reclamation, File $file, FileService $fileService)
|
|
|
{
|
|
{
|
|
|
$reclamation->photos_after()->detach($file);
|
|
$reclamation->photos_after()->detach($file);
|
|
|
Storage::disk('public')->delete($file->path);
|
|
Storage::disk('public')->delete($file->path);
|
|
|
$file->delete();
|
|
$file->delete();
|
|
|
- return redirect()->route('reclamations.show', $reclamation);
|
|
|
|
|
|
|
+ return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function uploadDocument(Request $request, Reclamation $reclamation, FileService $fileService)
|
|
public function uploadDocument(Request $request, Reclamation $reclamation, FileService $fileService)
|
|
@@ -153,15 +156,15 @@ class ReclamationController extends Controller
|
|
|
}
|
|
}
|
|
|
$reclamation->documents()->syncWithoutDetaching($f);
|
|
$reclamation->documents()->syncWithoutDetaching($f);
|
|
|
|
|
|
|
|
- return redirect()->route('reclamations.show', $reclamation);
|
|
|
|
|
|
|
+ return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function deleteDocument(Reclamation $reclamation, File $file)
|
|
|
|
|
|
|
+ public function deleteDocument(Request $request, Reclamation $reclamation, File $file)
|
|
|
{
|
|
{
|
|
|
$reclamation->documents()->detach($file);
|
|
$reclamation->documents()->detach($file);
|
|
|
Storage::disk('public')->delete($file->path);
|
|
Storage::disk('public')->delete($file->path);
|
|
|
$file->delete();
|
|
$file->delete();
|
|
|
- return redirect()->route('reclamations.show', $reclamation);
|
|
|
|
|
|
|
+ return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function uploadAct(Request $request, Reclamation $reclamation, FileService $fileService)
|
|
public function uploadAct(Request $request, Reclamation $reclamation, FileService $fileService)
|
|
@@ -175,15 +178,15 @@ class ReclamationController extends Controller
|
|
|
}
|
|
}
|
|
|
$reclamation->acts()->syncWithoutDetaching($f);
|
|
$reclamation->acts()->syncWithoutDetaching($f);
|
|
|
|
|
|
|
|
- return redirect()->route('reclamations.show', $reclamation);
|
|
|
|
|
|
|
+ return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function deleteAct(Reclamation $reclamation, File $file)
|
|
|
|
|
|
|
+ public function deleteAct(Request $request, Reclamation $reclamation, File $file)
|
|
|
{
|
|
{
|
|
|
$reclamation->acts()->detach($file);
|
|
$reclamation->acts()->detach($file);
|
|
|
Storage::disk('public')->delete($file->path);
|
|
Storage::disk('public')->delete($file->path);
|
|
|
$file->delete();
|
|
$file->delete();
|
|
|
- return redirect()->route('reclamations.show', $reclamation);
|
|
|
|
|
|
|
+ return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function updateDetails(StoreReclamationDetailsRequest $request, Reclamation $reclamation)
|
|
public function updateDetails(StoreReclamationDetailsRequest $request, Reclamation $reclamation)
|
|
@@ -208,25 +211,27 @@ class ReclamationController extends Controller
|
|
|
->delete();
|
|
->delete();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- return redirect()->route('reclamations.show', $reclamation);
|
|
|
|
|
|
|
+ return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function generateReclamationPack(Reclamation $reclamation)
|
|
|
|
|
|
|
+ public function generateReclamationPack(Request $request, Reclamation $reclamation)
|
|
|
{
|
|
{
|
|
|
GenerateReclamationPack::dispatch($reclamation, auth()->user()->id);
|
|
GenerateReclamationPack::dispatch($reclamation, auth()->user()->id);
|
|
|
- return redirect()->route('reclamations.show', $reclamation)->with(['success' => 'Задача генерации документов создана!']);
|
|
|
|
|
|
|
+ return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')])
|
|
|
|
|
+ ->with(['success' => 'Задача генерации документов создана!']);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function generatePhotosBeforePack(Reclamation $reclamation)
|
|
|
|
|
|
|
+ public function generatePhotosBeforePack(Request $request, Reclamation $reclamation)
|
|
|
{
|
|
{
|
|
|
GenerateFilesPack::dispatch($reclamation, $reclamation->photos_before, auth()->user()->id, 'Фото проблемы');
|
|
GenerateFilesPack::dispatch($reclamation, $reclamation->photos_before, auth()->user()->id, 'Фото проблемы');
|
|
|
- return redirect()->back()->with(['success' => 'Задача архивации создана!']);
|
|
|
|
|
|
|
+ return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')])
|
|
|
|
|
+ ->with(['success' => 'Задача архивации создана!']);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function generatePhotosAfterPack(Reclamation $reclamation)
|
|
|
|
|
|
|
+ public function generatePhotosAfterPack(Request $request, Reclamation $reclamation)
|
|
|
{
|
|
{
|
|
|
GenerateFilesPack::dispatch($reclamation, $reclamation->photos_after, auth()->user()->id, 'Фото после');
|
|
GenerateFilesPack::dispatch($reclamation, $reclamation->photos_after, auth()->user()->id, 'Фото после');
|
|
|
- return redirect()->back()->with(['success' => 'Задача архивации создана!']);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')])
|
|
|
|
|
+ ->with(['success' => 'Задача архивации создана!']); }
|
|
|
|
|
|
|
|
}
|
|
}
|