i'm building an API, i'm validating the input fields in my StoreLesson.php
public function rules()
{
return [
'title' => 'required',
'body' => 'required',
];
}
i'm using postman to test the API, things are working fine but when i send POST request with empty fields, in postman console in webview i'm getting redirected to welcom.blade.php
//LessonController.php
public function store(StoreLessons $request)
{
Lesson::create($request->all());
return response()->json($validator->errors(), 422); //i'm not getting any json with errors
//Lesson::create(input::all());
return $this->respondCreated('Lesson created successfully');
}
i want to display (return) the validator error as json
thank You