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
- Add [name] to fillable property to allow mass assignment on [App\Models\Project]
- Property [user] does not exist on this collection instance
- Laravel 10 Breeze Authentication Example
- How to create static page in Laravel
- How to create belongstomany relation using custom name on custom pivot table
- How to get date from created_at field in laravel
- Delete file from amazon s3 bucket using Laravel
- If condition in Laravel 9
- Laravel save object to database
- How to get specific columns using Laravel eloquent methods
- Comment .env file in laravel
- Redirect to previous page or url in laravel
- Call to a member function getRelationExistenceQuery() on array in Laravel
- SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'user_id'
- How to get route method name in Laravel
- Insert values in pivot table dynamically in laravel
- Cannot end a section without first starting one
- How to generate .env file for laravel?
- Use withCount() to Calculate Child Relationship Records
- How to check data inserted or deleted in pivot after toggle method
- Delete all related comments on deleting a post in Laravel
- Store logged in user details in session and display in view in laravel
- How to create laravel project using jetstream
- Create a record if not exist in laravel
- How to add unique records in pivot columns of Laravel pivot table