CarlosCarucce CarlosCarucce - 6 months ago 16
PHP Question

How to create unique constraints in laravel 5.2?

How do I create unique constraints using laravel 5.2 Schema Builder?

Schema::create('my_pivot', function(Blueprint $table){



//Here i need to add an unique constraint to 'key1' + 'key2'



You can pass an array to the unique method.

$table->unique(['key1', 'key2']);

Documented under Available Index Types in the manual