From 4d524695e393fa46b8583e565ff5be0b98f66ab2 Mon Sep 17 00:00:00 2001 From: Corentin Huet Date: Fri, 5 Sep 2025 16:44:02 +0200 Subject: [PATCH] feat: add timestamps to customerables table --- .gitignore | 3 ++ app/Models/Customer.php | 6 ++-- ...09_05_161808_alter_customerables_table.php | 28 +++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 database/migrations/2025_09_05_161808_alter_customerables_table.php diff --git a/.gitignore b/.gitignore index 30159d2c..3582adbc 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,9 @@ npm-debug.log yarn-error.log .npmrc /tests/coverage +.zshrc +.npm/ +.composer/ # Ignore public favicon /public/android-chrome-192x192.png diff --git a/app/Models/Customer.php b/app/Models/Customer.php index cbafc5e4..8c4b6e18 100644 --- a/app/Models/Customer.php +++ b/app/Models/Customer.php @@ -500,7 +500,7 @@ class Customer extends Authenticatable implements MustVerifyEmail */ public function recipes(): \Illuminate\Database\Eloquent\Relations\MorphToMany { - return $this->morphedByMany(Recipe::class, 'customerable')->with('products', 'consumptionMoment'); + return $this->morphedByMany(Recipe::class, 'customerable')->with('products', 'consumptionMoment')->withTimestamps(); } /** @@ -510,7 +510,7 @@ class Customer extends Authenticatable implements MustVerifyEmail */ public function products(): \Illuminate\Database\Eloquent\Relations\MorphToMany { - return $this->morphedByMany(Product::class, 'customerable'); + return $this->morphedByMany(Product::class, 'customerable')->withTimestamps(); } /** @@ -520,6 +520,6 @@ class Customer extends Authenticatable implements MustVerifyEmail */ public function surveyAnswers(): \Illuminate\Database\Eloquent\Relations\MorphToMany { - return $this->morphedByMany(SurveysAnswer::class, 'customerable')->with('newsClub'); + return $this->morphedByMany(SurveysAnswer::class, 'customerable')->with('newsClub')->withTimestamps(); } } diff --git a/database/migrations/2025_09_05_161808_alter_customerables_table.php b/database/migrations/2025_09_05_161808_alter_customerables_table.php new file mode 100644 index 00000000..2b515e6c --- /dev/null +++ b/database/migrations/2025_09_05_161808_alter_customerables_table.php @@ -0,0 +1,28 @@ +timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('customerables', function (Blueprint $table) { + $table->dropTimestamps(); + }); + } +};