1

I want to input rows where combination of customername, pan, mobile columns must be unique so i used

$table->unique('customername', 'pan', 'mobile');

Now whether all three value's combination will be unique or either two of three will be unique?

What I want is combination of all three must be unique.

I got this error while trying above

"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))"

complete schema

        $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();
Dev Abel
  • 123
  • 1
  • 2
  • 12

1 Answers1

2

According to this answer you may try:

$table->unique(array('customername', 'pan', 'mobile'));
Community
  • 1
  • 1
Fabian Kleiser
  • 2,988
  • 3
  • 27
  • 44