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

Mel*_*vin 2 php validation schema laravel laravel-4

我有这个架构:

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

        $table->unique(array('lname', 'fname'));
    });
Run Code Online (Sandbox Code Playgroud)

我的问题是,如何验证这些独特的字段?

我试过这个,但我知道这是错的......

public static $rules = array(
    'lname' => 'unique:members',
    'fname' => 'unique:members'
);
Run Code Online (Sandbox Code Playgroud)

任何帮助表示赞赏.. :)

rah*_*mat 6

你应该使用这个包https://github.com/felixkiss/uniquewith-validator

像这样用它:

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