Instead of return a JSON response, redirect back to the previous screen (#9055)

This commit is contained in:
Ivan Nieto 2021-01-27 14:01:42 -06:00 committed by GitHub
parent 0031fab0fe
commit 6e83679528
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -38,7 +38,7 @@ class UserFilesController extends Controller
$filename = 'user-' . $user->id . '-' . str_random(8); $filename = 'user-' . $user->id . '-' . str_random(8);
$filename .= '-' . str_slug($file->getClientOriginalName()) . '.' . $extension; $filename .= '-' . str_slug($file->getClientOriginalName()) . '.' . $extension;
if (!$file->move($destinationPath, $filename)) { 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 //Log the uploaded file to the log
$logAction = new Actionlog(); $logAction = new Actionlog();
@ -58,9 +58,9 @@ class UserFilesController extends Controller
$logActions[] = $logAction; $logActions[] = $logAction;
} }
// dd($logActions); // dd($logActions);
return JsonResponse::create($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'));
} }