📜  Laravel 添加外键约束 - 无论代码示例

📅  最后修改于: 2022-03-11 14:56:58.211000             🧑  作者: Mango

代码示例1
$table->foreignId('user_id')
      ->constrained("users") <- // You don't need to specify table if it matched laravel naming conventions.
      ->onUpdate('cascade')
      ->onDelete('cascade');