| 1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
-
- namespace Database\Factories;
-
- use App\Models\DiscountCode;
- use App\Models\Store;
- use Illuminate\Database\Eloquent\Factories\Factory;
-
- /**
- * @extends Factory<DiscountCode>
- */
- class DiscountCodeFactory extends Factory
- {
- /**
- * @return array<string, mixed>
- */
- public function definition(): array
- {
- return [
- 'store_id' => Store::factory(),
- 'code' => 'SAVE'.fake()->unique()->numberBetween(10, 9999),
- 'type' => DiscountCode::PERCENT,
- 'value' => 10,
- 'active' => true,
- 'times_used' => 0,
- ];
- }
-
- public function fixed(int $sen): static
- {
- return $this->state(['type' => DiscountCode::FIXED, 'value' => $sen]);
- }
-
- public function percent(int $percent): static
- {
- return $this->state(['type' => DiscountCode::PERCENT, 'value' => $percent]);
- }
- }
|