Thursday, 27 August 2015

Laravel Unique Validation

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:

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 :)

 

No comments:

Post a Comment

Thanks for your valuable comments.

Gmail: Download blocked file

Hi, today we are going to learn, how to download blocked file in gmail. Sometimes you see following message in gmail: and you can...