I have written this code in the Controller as the Action of a form:
public function submitAsk(Request $request)
{
$rules = [
'title' => 'required|max:255',
'description' => 'required|max:1000',
'category' => 'required',
'tags' => 'required',
];
$messages = [
'required' => ':attribute can not be empty'
];
$validator = Validator::make($request, $rules, $messages);
if ($validator->fails()) {
return redirect('questions/ask')
->withErrors($validator)
->withInput();
}
...
}
But I get this error:
IlluminateValidationFactory::make(): Argument #1 ($data) must be of type array, IlluminateHttpRequest given, called in C:projectnamevendorlaravelframeworksrcIlluminateSupportFacadesFacade.php on line 338
So what’s going wrong here?
How can I solve this issue?