我有这个架构:
Schema::create('members', function(Blueprint $table) { $table->increments('id'); $table->string('lname'); $table->string('fname'); $table->integer('mname'); $table->unique(array('lname', 'fname')); });
我的问题是,如何验证这些独特的字段?
我试过这个,但我知道这是错的......
public static $rules = array( 'lname' => 'unique:members', 'fname' => 'unique:members' );
任何帮助表示赞赏.. :)
你应该使用这个包https://github.com/felixkiss/uniquewith-validator
像这样用它:
$rules = array( '<field1>' => 'unique_with:<table>,<field2>[,<field3>,...,<ignore_rowid>]', );