parfum/database/factories/ProductFactory.php
Yoga Pangestu c4b90acf53 feat: membuat factory seluruh model
- menyesuaikan model jika ada yang salah seperti kurangnya trait SoftDeletes, casting yang salah, relasi yang kurang dan lainnya
- memperbaiki enum di migrasi
2025-12-09 08:25:07 +07:00

28 lines
843 B
PHP

<?php
namespace Database\Factories;
use App\Models\Product;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class ProductFactory extends Factory
{
protected $model = Product::class;
public function definition(): array
{
$name = $this->faker->unique()->words(2, true);
return [
'name' => Str::title($name),
'slug' => Str::slug($name.'-'.$this->faker->unique()->randomNumber()),
'sku' => strtoupper($this->faker->unique()->bothify('PRD-#####')),
'cost_price' => $this->faker->numberBetween(20000, 150000),
'sale_price' => $this->faker->numberBetween(30000, 200000),
'point_per_pcs' => $this->faker->numberBetween(1, 50),
'description' => $this->faker->optional()->paragraph(),
];
}
}