*/ class ProductFactory extends Factory { /** * The name of the factory's corresponding model. * * @var string */ protected $model = Product::class; /** * Define the model's default state. * * @return array */ public function definition(): array { return [ 'title' => $this->faker->sentence(3), 'description' => $this->faker->paragraph(), 'website_url' => $this->faker->url(), 'thumbnail' => null, 'user_id' => User::factory(), 'category_id' => Category::factory(), 'status' => 'pending', 'approved_at' => null, 'rejected_at' => null, 'free_tier' => false, 'open_source' => false, 'eu_hosted' => false, 'eu_made' => false, ]; } /** * Indicate that the product is approved. */ public function approved(): static { return $this->state(fn (array $attributes) => [ 'status' => 'approved', 'approved_at' => now(), 'rejected_at' => null, ]); } /** * Indicate that the product is pending. */ public function pending(): static { return $this->state(fn (array $attributes) => [ 'status' => 'pending', 'approved_at' => null, 'rejected_at' => null, ]); } /** * Indicate that the product is rejected. */ public function rejected(): static { return $this->state(fn (array $attributes) => [ 'status' => 'rejected', 'approved_at' => null, 'rejected_at' => now(), ]); } }