Correctly call the validator in the response if it fails

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2023-10-31 15:30:38 +00:00
parent ae90f9defa
commit 57372fc82a

View file

@ -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);
}