public function post(Request $request){
$validator = Validator::make($request->all(),[
'title'=>'required',
'job_type_id'=>'required|exists:job_type,id',
'work_level_id'=>'required|exists:work_level,id',
'no_of_candidate'=>'required',
]);
if ( $validator->fails()) {
return $this->validationErrors($validator->errors());
}
}
this is my validation code which i have written in my controller.I just want to remove this validation from controller. So that i can make same Form Request Validation what we do in the laravel like this
public function rules()
{
return [
'name'=>'required|unique:course,name'
];
}
public function messages(){
return [
'name.required'=>__('message.validation.course.name'),
'name.unique'=>__('message.validation.course.unique')
];
}
Considering you are using Lumen 8x(you can change the version in the link I sent here), from the docs that you can read here:
And i continuous by saying:
And it also says: