diff --git a/database/migrations/task4/2021_11_09_082205_create_products_table.php b/database/migrations/task4/2021_11_09_082205_create_products_table.php index 78636019..6253f189 100644 --- a/database/migrations/task4/2021_11_09_082205_create_products_table.php +++ b/database/migrations/task4/2021_11_09_082205_create_products_table.php @@ -16,7 +16,7 @@ public function up() // TASK: Edit this file, so that deleting category would auto-delete its products Schema::create('products', function (Blueprint $table) { $table->id(); - $table->foreignId('category_id')->constrained(); + $table->foreignId('category_id')->constrained()->cascadeOnDelete(); $table->string('name'); $table->timestamps(); });