email unique validation in laravel update code example
Example 1: laravel unique validation
public function store(Request $request)
{
$validatedData = $request->validate([
'title' => 'required|unique:posts|max:255',
'body' => 'required',
]);
}
Example 2: laravel validation unique email
'email' => 'unique:users,email_address,'.$user->id
Example 3: 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)
]
];
}