From 6e8367952886fef19466ab57ac056a8facdf91e7 Mon Sep 17 00:00:00 2001 From: Ivan Nieto Date: Wed, 27 Jan 2021 14:01:42 -0600 Subject: [PATCH] Instead of return a JSON response, redirect back to the previous screen (#9055) --- app/Http/Controllers/Users/UserFilesController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Users/UserFilesController.php b/app/Http/Controllers/Users/UserFilesController.php index 1776a34c3b..bce241aee2 100644 --- a/app/Http/Controllers/Users/UserFilesController.php +++ b/app/Http/Controllers/Users/UserFilesController.php @@ -38,7 +38,7 @@ class UserFilesController extends Controller $filename = 'user-' . $user->id . '-' . str_random(8); $filename .= '-' . str_slug($file->getClientOriginalName()) . '.' . $extension; if (!$file->move($destinationPath, $filename)) { - return JsonResponse::create(["error" => "Unabled to move file"], 500); + return redirect()->back()->with('error', trans('admin/users/message.upload.invalidfiles')); } //Log the uploaded file to the log $logAction = new Actionlog(); @@ -57,10 +57,10 @@ class UserFilesController extends Controller } $logActions[] = $logAction; } -// dd($logActions); - return JsonResponse::create($logActions); + // dd($logActions); + return redirect()->back()->with('success', trans('admin/users/message.upload.success')); } - return JsonResponse::create(["error" => "No User associated with this request"], 500); + return redirect()->back()->with('error', trans('admin/users/message.upload.nofiles')); }