Hi, You can find most of the things on the following link regarding unique validation in Laravel.
http://brianretterer.com/quick-tip-laravel-unique-validation/
But I would like to add one more case to make it little easy to understand:
The query that this will give you is:
It will check unique article name per user. Multiple users can have same article name but one user can't have same article name again, only once.
Thanks!!!!!!!!! Enjoy Programming :)
http://brianretterer.com/quick-tip-laravel-unique-validation/
But I would like to add one more case to make it little easy to understand:
articleName => unique:articles,article_name,{isset(article_id) : article_id : NULL },article_id,user_id,{user_id}
The query that this will give you is:
Select count(*)
as
aggregate from articles where article_name = <given_article_name>
and article_id <>
{article_id}
and user_id={user_id}
It will check unique article name per user. Multiple users can have same article name but one user can't have same article name again, only once.
Thanks!!!!!!!!! Enjoy Programming :)
Comments
Post a Comment
Thanks for your valuable comments.