Answers for "custom condition in unique validation in laravel"

PHP
1

laravel unique validation

/**
 * Store a new blog post.
 *
 * @param  Request  $request
 * @return Response
 */

public function store(Request $request)
{
    $validatedData = $request->validate([
        'title' => 'required|unique:posts|max:255',
        'body' => 'required',
    ]);

    // The blog post is valid...
}
Posted by: Guest on June-03-2020
1

set unique value validation for laravel form request

use Illuminate\Validation\Rule;

public function rules()
{
    return [
	    'title' => [
		    'required',
		    Rule::unique('posts', 'title')->ignore($this->post)
	    ]
    ]; 
}
Posted by: Guest on January-03-2021

Code answers related to "custom condition in unique validation in laravel"

Browse Popular Code Answers by Language