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'); + } +};