36 lines
810 B
PHP
36 lines
810 B
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\ProductStatus;
|
|
use App\Models\Product;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* @extends Factory<Product>
|
|
*/
|
|
class ProductFactory extends Factory
|
|
{
|
|
public function definition(): array
|
|
{
|
|
$name = fake()->unique()->words(3, true);
|
|
|
|
return [
|
|
'name' => Str::limit($name, 200, ''),
|
|
'slug' => Str::slug($name),
|
|
'description' => fake()->optional()->paragraph(),
|
|
'is_active' => true,
|
|
'status' => ProductStatus::APPROVED,
|
|
'was_ever_approved' => true,
|
|
];
|
|
}
|
|
|
|
public function inactive(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'is_active' => false,
|
|
]);
|
|
}
|
|
}
|