From 0591b5913c814420d86a0956dae4a07363119752 Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 9 Feb 2022 00:30:31 +0100 Subject: [PATCH] Update 2022_02_06_194000_create_shoppingcart_items_table.php --- .../2022_02_06_194000_create_shoppingcart_items_table.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Database/migrations/2022_02_06_194000_create_shoppingcart_items_table.php b/src/Database/migrations/2022_02_06_194000_create_shoppingcart_items_table.php index f717e86..efb6634 100644 --- a/src/Database/migrations/2022_02_06_194000_create_shoppingcart_items_table.php +++ b/src/Database/migrations/2022_02_06_194000_create_shoppingcart_items_table.php @@ -19,9 +19,12 @@ class CreateShoppingcartItemsTable extends Migration /* Relation CartItem to Cart */ $table->unsignedBigInteger('cart_id'); $table->foreign('cart_id')->references('id')->on(Config::get('cart.database.tables.cart')); - + /* Make id and rowid primary so there can not be duplicates */ $table->primary(['cart_id', 'row_id']); + + /* Columns required for the morphTo relationship being the id and FQCN of the model */ + $table->morphs('model'); /* The price of the CartItem */ $table->unsignedBigInteger('price')->nullable();