Laravel 4 - 如何验证多个字段的唯一性?

I have this schema:

Schema::create('members', function(Blueprint $table)
    {
        $table->increments('id');
        $table->string('lname');
        $table->string('fname');
        $table->integer('mname');

        $table->unique(array('lname', 'fname'));
    });

My problem is, how to validate these unique fields?

I tried this but I know this is wrong...

public static $rules = array(
    'lname' => 'unique:members',
    'fname' => 'unique:members'
);

Any help is appreciated.. :)

Try the following:

public static $rules = array(
    'lname' => 'unique:members,lname',
    'fname' => 'unique:members,fname'
);


 'lname' => 'unique:members,lname',
                            ^^^^^ "lname" is a column of members table

More info:

http://laravel.com/docs/validation#rule-unique

You should use this package https://github.com/felixkiss/uniquewith-validator

use it like this:

$rules = array(
    '<field1>' => 'unique_with:<table>,<field2>[,<field3>,...,<ignore_rowid>]',
);