Quellcode durchsuchen

Refactored models and migrations

Alexander Musikhin vor 1 Jahr
Ursprung
Commit
4fa2642883

+ 1 - 0
app/Models/ProductImage.php

@@ -7,5 +7,6 @@ use Illuminate\Database\Eloquent\Model;
 
 class ProductImage extends Model
 {
+    public $timestamps = false;
     protected $fillable = ['product_id', 'url'];
 }

+ 2 - 1
app/Models/ProductReview.php

@@ -6,5 +6,6 @@ use Illuminate\Database\Eloquent\Model;
 
 class ProductReview extends Model
 {
-    protected $fillable = ['product_id', 'rating', 'comment', 'reviewer_name', 'reviewer_email'];
+    public $timestamps = false;
+    protected $fillable = ['product_id', 'rating', 'comment', 'date', 'reviewer_name', 'reviewer_email'];
 }

+ 1 - 0
app/Models/Tag.php

@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
 
 class Tag extends Model
 {
+    public $timestamps = false;
     protected $fillable = ['name'];
 
     public function products(): BelongsToMany

+ 1 - 1
database/migrations/2024_08_29_102201_create_products_table.php

@@ -27,7 +27,7 @@ return new class extends Migration
             $table->decimal('height');
             $table->decimal('depth');
             $table->string('warranty_information');
-            $table->string('shipment_information');
+            $table->string('shipping_information');
             $table->string('availability_status');
             $table->string('return_policy');
             $table->string('minimum_order_quantity');

+ 1 - 1
database/migrations/2024_08_29_103420_create_tags_table.php

@@ -13,7 +13,7 @@ return new class extends Migration
     {
         Schema::create('tags', function (Blueprint $table) {
             $table->id();
-            $table->string('name');
+            $table->string('name')->unique();
         });
     }
 

+ 2 - 3
database/migrations/2024_08_29_103421_create_product_tags_table.php → database/migrations/2024_08_29_103421_create_product_tag_table.php

@@ -11,10 +11,9 @@ return new class extends Migration
      */
     public function up(): void
     {
-        Schema::create('product_tags', function (Blueprint $table) {
+        Schema::create('product_tag', function (Blueprint $table) {
             $table->unsignedBigInteger('product_id');
             $table->unsignedBigInteger('tag_id');
-            $table->timestamps();
         });
     }
 
@@ -23,6 +22,6 @@ return new class extends Migration
      */
     public function down(): void
     {
-        Schema::dropIfExists('product_tags');
+        Schema::dropIfExists('product_tag');
     }
 };

+ 3 - 3
database/migrations/2024_08_29_104219_create_reviews_table.php → database/migrations/2024_08_29_104219_create_product_reviews_table.php

@@ -11,14 +11,14 @@ return new class extends Migration
      */
     public function up(): void
     {
-        Schema::create('reviews', function (Blueprint $table) {
+        Schema::create('product_reviews', function (Blueprint $table) {
             $table->id();
             $table->foreignId('product_id')->constrained('products')->cascadeOnDelete();
             $table->unsignedInteger('rating');
             $table->text('comment');
+            $table->timestamp('date');
             $table->string('reviewer_name');
             $table->string('reviewer_email');
-            $table->timestamps();
         });
     }
 
@@ -27,6 +27,6 @@ return new class extends Migration
      */
     public function down(): void
     {
-        Schema::dropIfExists('reviews');
+        Schema::dropIfExists('product_reviews');
     }
 };

+ 0 - 1
database/migrations/2024_08_29_104518_create_product_images_table.php

@@ -15,7 +15,6 @@ return new class extends Migration
             $table->id();
             $table->foreignId('product_id')->constrained('products')->cascadeOnDelete();
             $table->text('url');
-            $table->timestamps();
         });
     }