*/ class CouponFactory extends Factory { /** * Define the model's default state. * * @return array */ public function definition(): array { $type = $this->faker->randomElement([ CouponType::PERCENTAGE, CouponType::FLAT, ]); $amount = $type === CouponType::PERCENTAGE ? $this->faker->numberBetween(5, 40) : $this->faker->numberBetween(5, 150); return [ 'name' => $this->faker->words(3, true), 'code' => Str::upper(Str::random(8)), 'type' => $type, 'amount' => $amount, 'currency' => $type === CouponType::PERCENTAGE ? null : 'EUR', 'status' => CouponStatus::ACTIVE, 'is_stackable' => false, 'enabled_for_checkout' => true, 'auto_apply' => false, 'usage_limit' => 100, 'per_customer_limit' => 1, 'description' => $this->faker->sentence(), 'metadata' => ['note' => 'factory'], 'starts_at' => now()->subDay(), 'ends_at' => now()->addMonth(), 'paddle_discount_id' => 'dsc_'.Str::upper(Str::random(10)), 'paddle_mode' => 'standard', ]; } }