feat(goods): Menambahkan kolom untuk menentukan harga poin per pcs/ml
- casting kolom tersebut - menyesuaikan seeder nya
This commit is contained in:
parent
5427260c5a
commit
a78c490f7d
@ -27,6 +27,7 @@ protected function casts(): array
|
||||
return [
|
||||
'cost_price' => 'int',
|
||||
'sale_price' => 'int',
|
||||
'point_per_pcs' => 'int',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ protected function casts(): array
|
||||
'concentration' => Concentration::class,
|
||||
'cost_price' => 'int',
|
||||
'sale_price' => 'int',
|
||||
'point_per_ml' => 'int',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -24,6 +24,7 @@ protected function casts(): array
|
||||
return [
|
||||
'cost_price' => 'int',
|
||||
'sale_price' => 'int',
|
||||
'point_per_pcs' => 'int',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -21,6 +21,7 @@ public function up(): void
|
||||
$table->enum('concentration', [Concentration::values()])->default(Concentration::EXTRAIT_DE_PERFUME)->comment(Concentration::comment());
|
||||
$table->unsignedInteger('cost_price')->default(0);
|
||||
$table->unsignedInteger('sale_price')->default(0);
|
||||
$table->unsignedInteger('point_per_ml');
|
||||
$table->string('base_notes')->nullable();
|
||||
$table->string('middle_notes')->nullable();
|
||||
$table->string('top_notes')->nullable();
|
||||
|
||||
@ -18,6 +18,7 @@ public function up(): void
|
||||
$table->string('sku', 20)->unique();
|
||||
$table->unsignedInteger('cost_price')->default(0);
|
||||
$table->unsignedInteger('sale_price')->default(0);
|
||||
$table->unsignedInteger('point_per_pcs');
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
$table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate();
|
||||
|
||||
@ -18,6 +18,7 @@ public function up(): void
|
||||
$table->unsignedInteger('size');
|
||||
$table->unsignedInteger('cost_price')->default(0);
|
||||
$table->unsignedInteger('sale_price')->default(0);
|
||||
$table->unsignedInteger('point_per_pcs');
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
$table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate();
|
||||
|
||||
@ -24,15 +24,16 @@ public function run(): void
|
||||
['name' => 'Botol Refill 500ml Bulk', 'size' => 500, 'cost_price' => 50000],
|
||||
];
|
||||
|
||||
foreach ($bottles as $index => $item) {
|
||||
$slug = Str::slug($item['name']);
|
||||
foreach ($bottles as $bottle) {
|
||||
$slug = Str::slug($bottle['name']);
|
||||
|
||||
$bottle = Bottle::create([
|
||||
'name' => $item['name'],
|
||||
'name' => $bottle['name'],
|
||||
'slug' => $slug,
|
||||
'size' => $item['size'],
|
||||
'cost_price' => $item['cost_price'],
|
||||
'sale_price' => $item['cost_price'] * 2,
|
||||
'size' => $bottle['size'],
|
||||
'cost_price' => $bottle['cost_price'],
|
||||
'sale_price' => $bottle['cost_price'] * 2,
|
||||
'point_per_pcs' => round($bottle['cost_price'] / 100),
|
||||
'description' => fake()->sentence(10),
|
||||
]);
|
||||
|
||||
|
||||
@ -34,6 +34,8 @@ public function run(): void
|
||||
$slug = Str::slug($name);
|
||||
$sku = Str::upper(Str::random(3)).'-'.str_pad($index + 1, 4, '0', STR_PAD_LEFT);
|
||||
|
||||
$salePrice = fake()->numberBetween(25, 50) * 100;
|
||||
|
||||
$perfume = Perfume::create([
|
||||
'brand_id' => $brand->id,
|
||||
'name' => $name,
|
||||
@ -41,7 +43,8 @@ public function run(): void
|
||||
'sku' => $sku,
|
||||
'concentration' => fake()->randomElement(Concentration::values()),
|
||||
'cost_price' => fake()->numberBetween(5, 11) * 100,
|
||||
'sale_price' => fake()->numberBetween(25, 50) * 100,
|
||||
'sale_price' => $salePrice,
|
||||
'point_per_ml' => round($salePrice / 100),
|
||||
'base_notes' => fake()->optional()->randomElement(['Amber', 'Musk', 'Vanilla', 'Sandalwood', 'Leather']),
|
||||
'middle_notes' => fake()->optional()->randomElement(['Rose', 'Jasmine', 'Patchouli', 'Cedarwood', 'Iris']),
|
||||
'top_notes' => fake()->optional()->randomElement(['Citrus', 'Bergamot', 'Pepper', 'Mint', 'Lavender']),
|
||||
|
||||
@ -28,12 +28,15 @@ public function run(): void
|
||||
$slug = Str::slug($name);
|
||||
$sku = Str::upper(Str::random(3)).'-'.str_pad($index + 1, 4, '0', STR_PAD_LEFT);
|
||||
|
||||
$salePrice = fake()->numberBetween(15, 200) * 1000;
|
||||
|
||||
$product = Product::create([
|
||||
'name' => $name,
|
||||
'slug' => $slug,
|
||||
'sku' => $sku,
|
||||
'cost_price' => fake()->numberBetween(15, 80) * 1000,
|
||||
'sale_price' => fake()->numberBetween(15, 200) * 1000,
|
||||
'sale_price' => $salePrice,
|
||||
'point_per_pcs' => round($salePrice / 100),
|
||||
'description' => fake()->sentence(12),
|
||||
]);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user