Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel 8 foreign key migration

use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesSchema;

Schema::table('posts', function (Blueprint $table) {
    $table->unsignedBigInteger('user_id');

    $table->foreign('user_id')->references('id')->on('users');
});
Source by laravel.com #
 
PREVIOUS NEXT
Tagged: #laravel #foreign #key #migration
ADD COMMENT
Topic
Name
9+5 =