From 57372fc82ab2f3c89ef1d6b372b76511de2738a0 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 31 Oct 2023 15:30:38 +0000 Subject: [PATCH] Correctly call the validator in the response if it fails Signed-off-by: snipe --- app/Http/Controllers/SettingsController.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index 7a7aa45b6e..b4acc4c5a0 100755 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -26,7 +26,7 @@ use Response; use App\Http\Requests\SlackSettingsRequest; use Illuminate\Support\Str; use Illuminate\Support\Facades\Artisan; -use Validator; +use Illuminate\Support\Facades\Validator; /** * This controller handles all actions related to Settings for @@ -1248,13 +1248,11 @@ class SettingsController extends Controller if (!$request->hasFile('file')) { return redirect()->route('settings.backups.index')->with('error', 'No file uploaded'); } else { + $max_file_size = Helper::file_upload_max_size(); - - $rules = [ + $validator = Validator::make($request->all(), [ 'file' => 'required|mimes:zip|max:'.$max_file_size, - ]; - - $validator = \Validator::make($request->all(), $rules); + ]); if ($validator->passes()) { @@ -1265,7 +1263,7 @@ class SettingsController extends Controller return redirect()->route('settings.backups.index')->with('success', 'File uploaded'); } - return redirect()->route('settings.backups.index')->withErrors($request->getErrors()); + return redirect()->route('settings.backups.index')->withErrors($validator); }