我想输入客户名称、平移、移动列的组合必须是唯一的行,所以我使用
$table->unique('customername', 'pan', 'mobile');
现在,这三个值的组合都是唯一的,还是三个值中的两个都是唯一的?
我想要的是这三者的组合必须是唯一的。
我在上面尝试时收到此错误
"SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'newCust' for key 'pan' (SQL: insert into `customers` (`customername`, `pan`, `customertype`, `email`, `mobile`, `offadd`, `now`, `referer_id`, `updated_at`, `created_at`) values (newCust, 1234, sasdfsdf, sdfsdf@sfdlfsdf.com, 4567, adsfasdf, sdfsdf, 2, 2014-11-23 09:47:43, 2014-11-23 09:47:43))"
完整架构
$table->increments('id');
$table->string('customername');
$table->string('pan');
$table->string('customertype');
$table->string('email');
$table->string('mobile');
$table->unique('customername', 'pan', 'mobile');
$table->text('offadd');
$table->text('comadd');
$table->string('website');
$table->string('now');
$table->string('companyname');
$table->date('dob');
$table->integer('referer_id');
$table->string('status');
$table->timestamps();
根据这个答案,你可以尝试:
$table->unique(array('customername', 'pan', 'mobile'));