I need to validate user table in which not repeated combination of (firstname and lastname). for example:- firstname=dc lastname=patel already exist in table. i need to prevent same entry next time.
相关问题
- How to execute MYSQL query in laravel?
- How can I add condition on mail notification larav
- How to use Markdown for textarea input field in La
- How do I pass a route parameter to Vue.js from Lar
- How to add number of days to a date?
相关文章
- Laravel 5 input old is empty
- Laravel dusk not working .env.dusk.local
- Read a .csv file into an array in Laravel
- Laravel Impossible to Create Root Directory
- Laravel 5 InvalidArgumentException in FileViewFind
- Composer error with GitHub OAuth token on fresh la
- Laravel ::pluck multiple columns
- How can I redirect with old input in Laravel?
You can use something simular to composite UNIQUE key in table if database provide this possibility.
http://dev.mysql.com/doc/refman/5.7/en/multiple-column-indexes.html
First check records count with the given firstname and lastname. If the count is '0' save the record or else show message.
Here is some code hint
with using laravel unique validation rule how can you allow users with same lastname but not firstname for registeration?
unique.firstname
Finally I have perfect solution for this.
Since Laravel 5.5 you can use elegant Rule class like: