close
Q: 如何在laravel migrations中設定兩個欄位組合為unique
A: 使用陣列把兩個欄位包起來傳進去
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'));
or (a little neater)
$table->unique(['mytext', 'user_id']);
轉自 https://stackoverflow.com/questions/20065697/schema-builder-laravel-migrations-unique-on-two-columns
--
全站熱搜
留言列表