且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

模式构建器laravel迁移在两列中是唯一的

更新时间:2022-06-18 22:22:11

第二个参数是手动设置唯一索引的名称.将数组用作第一个参数,以在多个列之间创建唯一键.

The second param is to manually set the name of the unique index. Use an array as the first param to create a unique key across multiple columns.

$table->unique(array('mytext', 'user_id'));

或(稍微整洁)

$table->unique(['mytext', 'user_id']);