
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
- Laravel create table migration with model
- In order to use the Auth::routes() method, please install the laravel/ui package
- Laravel hasmany select not working
- How to validate form input data in laravel
- How to add script on specific view file in laravel while extending layout
- Undefined property: stdClass::$title
- Class 'Facade\Ignition\IgnitionServiceProvider' not found
- How to pass data to multiple partial view files in laravel
- PhpMyAdmin - Error The mysqli extension is missing
- Global scope in Laravel with example
- Fatal error: Uncaught Error: Class "Illuminate\Foundation\Application" not found
- Array to string conversion laravel Controller
- Method Illuminate\Events\Dispatcher::fire does not exist
- How to add columns in existing table using migration in laravel
- How to get random string in Laravel
- Laravel create default admin user
- Validation errors for multiple forms on same page Laravel
- Submit form without CSRF token in Laravel
- Method Illuminate\Database\Eloquent\Collection::appends does not exist
- Laravel clone model
- How to get all route list
- Send id with route Laravel
- Call to a member function pluck() on null
- How to get query string value in laravel
- How to send ID to another page in Laravel