Suppose I am editing a post, when I submit the form I check if the post exists in the database with the id like below
$post = Post::where('id', '=', $request['post_id'] );
if ( $post ->exists() ) {
// Update the post
}
But is there any way I can check with laravel validator? Right now my validation function looks like this.
$this->validate($request, [
'post_id' => 'required',
'post_title' => 'required',
'post_content' => 'required',
....
....
]);