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
- Pass value from controller to model in laravel
- Route prefix with auth middleware in laravel
- Add class to body in laravel view
- Send post data from controller to view
- How to get count of all records created at yesterday
- Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails
- How to create project_user pivot table in laravel
- Add a subselect based on relationship using withAggregate method
- How to pass two variables in HREF in laravel
- Class 'App\Rules\Hash' not found in Laravel
- Post table seeder laravel 10
- Route [password.request] not defined
- How to display HTML tags In Laravel blade
- How to get all posts which contains comments in laravel
- How to validate URL with https using regex in laravel
- How to change default timestamp fields name in Laravel
- How to get all route list
- How to get records in random order in laravel
- The POST method is not supported for this route. Supported methods: PUT.
- How to create and run user seeder in laravel
- Remove array keys and values if it does not exist in other array in Laravel
- Trying to get property 'title' of non-object
- Laravel clone model
- How to create new user without form submission in laravel
- How to pass data to route in laravel?