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
- Delete records with relationship in laravel
- Laravel file size validation not working
- Session Doesn't Work on Redirect
- How to remove P tag from CkEditor in Laravel?
- How to validate URL with https using regex in laravel
- Laravel create default admin user
- Link storage folder in laravel 8
- How to get all posts which contains comments in laravel
- How to get selected categories on edit record with Select2
- How to create laravel project using jetstream
- How to add background image to div using Tailwindcss, Vite in Laravel Environment
- Laravel 11 step by step instructions to upload file in storage directory and display in blade file
- Run artisan command to generate key in laravel
- How to add foreign key in laravel using migration
- Send OTP using textlocal api in laravel
- Class 'App\Http\Controllers\User' not found
- Laravel route parameter
- The openssl extension is required for SSL/TLS protection but is not available
- Add [name] to fillable property to allow mass assignment on [App\Models\Project]
- Fatal error: Uncaught Error: Class "Illuminate\Foundation\Application" not found
- Call to undefined method Illuminate\Support\Facades\Request::all()
- Remove array keys and values if it does not exist in other array in Laravel
- How to print form data in laravel
- Laravel 11 project setup on localhost using breeze with blade step by step
- How to get last record from object collection in laravel