diff --git a/backend/app/Models/Product.php b/backend/app/Models/Product.php index fe1aa62..29eedde 100644 --- a/backend/app/Models/Product.php +++ b/backend/app/Models/Product.php @@ -26,6 +26,7 @@ class Product extends Model 'sku', 'short_description', 'description', + 'thumbnail_path', 'price', 'stock_quantity', 'active', diff --git a/backend/database/factories/ProductFactory.php b/backend/database/factories/ProductFactory.php index 5de72fc..9ff0e16 100644 --- a/backend/database/factories/ProductFactory.php +++ b/backend/database/factories/ProductFactory.php @@ -29,6 +29,7 @@ class ProductFactory extends Factory 'sku' => strtoupper(fake()->bothify('SKU-#####??')), 'short_description' => fake()->optional()->sentence(), 'description' => fake()->paragraphs(2, true), + 'thumbnail_path' => null, 'price' => fake()->randomFloat(2, 10, 10000), 'stock_quantity' => fake()->numberBetween(0, 5000), 'active' => fake()->boolean(90), diff --git a/backend/database/migrations/2026_04_29_000001_add_thumbnail_path_to_products_table.php b/backend/database/migrations/2026_04_29_000001_add_thumbnail_path_to_products_table.php new file mode 100644 index 0000000..43a180f --- /dev/null +++ b/backend/database/migrations/2026_04_29_000001_add_thumbnail_path_to_products_table.php @@ -0,0 +1,22 @@ +string('thumbnail_path')->nullable()->after('description'); + }); + } + + public function down(): void + { + Schema::table('products', function (Blueprint $table) { + $table->dropColumn('thumbnail_path'); + }); + } +}; diff --git a/backend/database/seeders/ProductSeeder.php b/backend/database/seeders/ProductSeeder.php index b646408..e227014 100644 --- a/backend/database/seeders/ProductSeeder.php +++ b/backend/database/seeders/ProductSeeder.php @@ -7,6 +7,7 @@ use App\Models\Category; use App\Models\Product; use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; +use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; class ProductSeeder extends Seeder @@ -531,6 +532,7 @@ class ProductSeeder extends Seeder 'slug' => Str::slug($product['name'].'-'.$product['sku']), 'short_description' => $product['short'], 'description' => $product['description'], + 'thumbnail_path' => "products/thumbnails/{$product['sku']}.png", 'price' => $product['price'], 'stock_quantity' => $product['stock'], 'active' => true,