Recently, I ran across an issue where I needed to validate across two fields in the database for uniqueness.  I searched all over the internet and was not able to find anything that was built into Laravel 4.  I really did not want to create my own validation for this one thing so I dug into the core code a little bit more.  With the help of dumping the queries that were happening during the validation, I found that Laravel Unique Validation was possible with the build in validation tool.

The current documentation (though being changed by Taylor) gives you a way to check for uniqueness on one field.

[php] email => unique:users,email_address
[/php]

The query that this will give you is:

[sql] select count(*) as aggregate from users where email_address = ?
[/sql]

Now, here is where it gets fun.  You can also provide two more values to exclude a row from being checked.  This would look like:

[php] email => unique:users,email_address,id,4
[/php]

The query that this will give you is:

[sql] select count(*) as aggregate from users where email_address = ? and id <> 4
[/sql]

This is good for the case where you want to exclude the user with an ID of 4.  This is great but what about my first issue.  How do you use this to check against multiple columns?  You would use the following

[php] email => unique:users,email_address,id,NULL,field_1,value_1,field_2,value_2,field_x,value_x
[/php]

The query that this will give you is:

[sql] select count(*) as aggregate from entries where email_address = ? and id <> null  and field_1 = value_1 and field_2 = value_2 and field_x=value_x
[/sql]

You can add as many fields as you need to validate against all using the Laravel Unique Validation tool built in.