
update email with unique validation in laravel
update email with unique validation in laravel
In this article, we will see how to solve "update email with unique validation in laravel".
You can update the email with unique validation on update user record with ignoring the current user email id.-
Update email with unique validation ignoring current email on update record in laravel
--PATH app\Http\Controllers\<YourController>.php$request->validate([ 'email' => ['required', 'string', 'email', 'max:255','unique:users,email,'.$userId] ]);
This code snippet will update the user email if email already does not exist in the table ignoring the current user email in the table. Variable $userId is the user which will be ignored while executing the unique validation in laravel which is the current user ID.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- Run artisan command to generate key in laravel
- Laravel 9 route group with controller
- How to display pivot table column value in laravel
- Link storage folder in laravel 8
- Create a record if not exist in laravel
- External link not working in laravel blade
- Undefined property: stdClass::$title
- How to get query string value in laravel
- Send id with route Laravel
- After image selected get validation error in laravel
- Define variable and use in Laravel controller method
- First and last item of the array using foreach iteration in laravel blade
- Route not defined in Laravel
- How to get all route list
- How to Get records between two dates in Laravel
- How to create static page in Laravel
- How to get route method name in Laravel
- Count all and get 10 records after where condition in laravel
- How to pass variable from controller to model in Laravel
- OrderBy on Eloquent relationships method in Laravel
- How to use or operator in laravel
- Display data in table using foreach in Laravel
- How to display a specific word from a string in laravel
- How to get random string in Laravel
- Argument 1 passed to Illuminate\Database\Query\Builder::cleanBindings() must be of the type array, null given