From 4217db8c624a23fa78a848c06fec243769f93c35 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sat, 28 Mar 2020 19:50:02 +0100 Subject: [PATCH] docs(laravel): add foreign key constraints --- backend/laravel.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/laravel.php b/backend/laravel.php index ec765a3..9a7f3c0 100644 --- a/backend/laravel.php +++ b/backend/laravel.php @@ -378,6 +378,14 @@ $table->dropUnique('users_email_unique'); // Drop a unique index fr $table->dropIndex('geo_state_index'); // Drop a basic index from the "geo" table. $table->dropSpatialIndex('geo_location_spatialindex'); // Drop a spatial index from the "geo" table (except SQLite). +// FOREIGN KEY CONSTRAINTS + +$table->foreign('user_id')->references('id')->on('users'); // Create foreign key constraints. +$table->dropForeign('posts_user_id_foreign'); // Drop foreign key (accepts an array of strings). + +Schema::enableForeignKeyConstraints(); // Enable foreign key constraints within your migrations. +Schema::disableForeignKeyConstraints(); // Disable foreign key constraints within your migrations. + /******************************************************************************************** * COLLECTION ELOQUENT METHODS * https://laravel.com/docs/5.7/collections