Answers for "how to create foreign key in laravel 8"

PHP
0

Laravel create foreign key column in migration

$table->foreignId('post_id')
                ->constrained()
                ->onUpdate('cascade')
                ->onDelete('cascade');
Posted by: Guest on July-18-2021
-1

foreign key string laravel

Schema::table('portfolios', function (Blueprint $table) {
            $table->string('filter_alias');
            $table->foreign('filter_alias')->cascadeOnDelete()->references('alias')->on('filters');
        });
Posted by: Guest on January-08-2021

Code answers related to "how to create foreign key in laravel 8"

Browse Popular Code Answers by Language