parfum/database/factories/ProductFactory.php

27 lines
776 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),
'description' => $this->faker->optional()->paragraph(),
];
}
}