feat(products): add thumbnail paths
This commit is contained in:
parent
3b05a045ed
commit
76afd14ffd
4 changed files with 26 additions and 0 deletions
|
|
@ -26,6 +26,7 @@ class Product extends Model
|
||||||
'sku',
|
'sku',
|
||||||
'short_description',
|
'short_description',
|
||||||
'description',
|
'description',
|
||||||
|
'thumbnail_path',
|
||||||
'price',
|
'price',
|
||||||
'stock_quantity',
|
'stock_quantity',
|
||||||
'active',
|
'active',
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ class ProductFactory extends Factory
|
||||||
'sku' => strtoupper(fake()->bothify('SKU-#####??')),
|
'sku' => strtoupper(fake()->bothify('SKU-#####??')),
|
||||||
'short_description' => fake()->optional()->sentence(),
|
'short_description' => fake()->optional()->sentence(),
|
||||||
'description' => fake()->paragraphs(2, true),
|
'description' => fake()->paragraphs(2, true),
|
||||||
|
'thumbnail_path' => null,
|
||||||
'price' => fake()->randomFloat(2, 10, 10000),
|
'price' => fake()->randomFloat(2, 10, 10000),
|
||||||
'stock_quantity' => fake()->numberBetween(0, 5000),
|
'stock_quantity' => fake()->numberBetween(0, 5000),
|
||||||
'active' => fake()->boolean(90),
|
'active' => fake()->boolean(90),
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('products', function (Blueprint $table) {
|
||||||
|
$table->string('thumbnail_path')->nullable()->after('description');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('products', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('thumbnail_path');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -7,6 +7,7 @@ use App\Models\Category;
|
||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class ProductSeeder extends Seeder
|
class ProductSeeder extends Seeder
|
||||||
|
|
@ -531,6 +532,7 @@ class ProductSeeder extends Seeder
|
||||||
'slug' => Str::slug($product['name'].'-'.$product['sku']),
|
'slug' => Str::slug($product['name'].'-'.$product['sku']),
|
||||||
'short_description' => $product['short'],
|
'short_description' => $product['short'],
|
||||||
'description' => $product['description'],
|
'description' => $product['description'],
|
||||||
|
'thumbnail_path' => "products/thumbnails/{$product['sku']}.png",
|
||||||
'price' => $product['price'],
|
'price' => $product['price'],
|
||||||
'stock_quantity' => $product['stock'],
|
'stock_quantity' => $product['stock'],
|
||||||
'active' => true,
|
'active' => true,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue