From 74bbf5a5c13e5c8117fdc35c2f53ad6be60159b9 Mon Sep 17 00:00:00 2001 From: kusowl Date: Thu, 15 Jan 2026 10:14:29 +0530 Subject: [PATCH] wip: add interaction schemas --- app/Enums/InteractionType.php | 13 ++++++++ app/Models/Deal.php | 6 ++++ app/Models/Interaction.php | 14 ++++++++ ...01_14_134306_create_interactions_table.php | 33 +++++++++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 app/Enums/InteractionType.php create mode 100644 app/Models/Interaction.php create mode 100644 database/migrations/2026_01_14_134306_create_interactions_table.php diff --git a/app/Enums/InteractionType.php b/app/Enums/InteractionType.php new file mode 100644 index 0000000..e644591 --- /dev/null +++ b/app/Enums/InteractionType.php @@ -0,0 +1,13 @@ +belongsTo(DealCategory::class, 'deal_category_id'); } + + public function interactions(): MorphMany + { + return $this->morphMany(Interaction::class, 'interactable'); + } } diff --git a/app/Models/Interaction.php b/app/Models/Interaction.php new file mode 100644 index 0000000..9e8417b --- /dev/null +++ b/app/Models/Interaction.php @@ -0,0 +1,14 @@ +morphTo(); + } +} diff --git a/database/migrations/2026_01_14_134306_create_interactions_table.php b/database/migrations/2026_01_14_134306_create_interactions_table.php new file mode 100644 index 0000000..28a4fa6 --- /dev/null +++ b/database/migrations/2026_01_14_134306_create_interactions_table.php @@ -0,0 +1,33 @@ +id(); + $table->foreignIdFor(User::class); + $table->foreignIdFor(Deal::class); + $table->enum('type', InteractionType::values()); + $table->timestamp('created_at')->useCurrent(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('interactions'); + } +};