Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Laravel adding Foreign Key Constraints

$table->foreignId('user_id')
      ->constrained("users") <- // You don't need to specify table if it matched laravel naming conventions.
      ->onUpdate('cascade')
      ->onDelete('cascade');
Source by laravel.com #
 
PREVIOUS NEXT
Tagged: #Laravel #adding #Foreign #Key #Constraints
ADD COMMENT
Topic
Name
8+6 =