PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, July 4, 2022

[FIXED] How validate unique email out of the user that is updating it in Laravel?

 July 04, 2022     authentication, email, laravel, php, validation     No comments   

Issue

I am using Laravel 5.2 and want to update user's account using validator.

I want to keep email field unique, but, if the user type his current email it will break. How can I update if the email is unique, except the user's own current email?


Solution

You can tell that to validators:

'email' => 'unique:users,email_address,'.$user->id

Check the docs, in section 'Forcing A Unique Rule To Ignore A Given ID'.



Answered By - Antonio Carlos Ribeiro
Answer Checked By - David Marino (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing