diff --git a/app/Models/Bottle.php b/app/Models/Bottle.php index f550092..bdb0577 100644 --- a/app/Models/Bottle.php +++ b/app/Models/Bottle.php @@ -27,6 +27,7 @@ protected function casts(): array return [ 'cost_price' => 'int', 'sale_price' => 'int', + 'point_per_pcs' => 'int', ]; } diff --git a/app/Models/Perfume.php b/app/Models/Perfume.php index 2c788e1..d900dbe 100644 --- a/app/Models/Perfume.php +++ b/app/Models/Perfume.php @@ -27,6 +27,7 @@ protected function casts(): array 'concentration' => Concentration::class, 'cost_price' => 'int', 'sale_price' => 'int', + 'point_per_ml' => 'int', ]; } diff --git a/app/Models/Product.php b/app/Models/Product.php index 355d722..02be9c4 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -24,6 +24,7 @@ protected function casts(): array return [ 'cost_price' => 'int', 'sale_price' => 'int', + 'point_per_pcs' => 'int', ]; } diff --git a/database/migrations/2025_10_01_112147_create_perfumes_table.php b/database/migrations/2025_10_01_112147_create_perfumes_table.php index 89362e6..125a030 100644 --- a/database/migrations/2025_10_01_112147_create_perfumes_table.php +++ b/database/migrations/2025_10_01_112147_create_perfumes_table.php @@ -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(); diff --git a/database/migrations/2025_10_02_013524_create_products_table.php b/database/migrations/2025_10_02_013524_create_products_table.php index 80825bc..5c3771f 100644 --- a/database/migrations/2025_10_02_013524_create_products_table.php +++ b/database/migrations/2025_10_02_013524_create_products_table.php @@ -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(); diff --git a/database/migrations/2025_10_02_020223_create_bottles_table.php b/database/migrations/2025_10_02_020223_create_bottles_table.php index 0c6c1ed..d2139b5 100644 --- a/database/migrations/2025_10_02_020223_create_bottles_table.php +++ b/database/migrations/2025_10_02_020223_create_bottles_table.php @@ -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(); diff --git a/database/seeders/BottleSeeder.php b/database/seeders/BottleSeeder.php index 0f3e4e1..890f803 100644 --- a/database/seeders/BottleSeeder.php +++ b/database/seeders/BottleSeeder.php @@ -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), ]); diff --git a/database/seeders/PerfumeSeeder.php b/database/seeders/PerfumeSeeder.php index a462e51..fd3cbf4 100644 --- a/database/seeders/PerfumeSeeder.php +++ b/database/seeders/PerfumeSeeder.php @@ -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']), diff --git a/database/seeders/ProductSeeder.php b/database/seeders/ProductSeeder.php index d1f31c5..632f476 100644 --- a/database/seeders/ProductSeeder.php +++ b/database/seeders/ProductSeeder.php @@ -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), ]);