45 lines
1.1 KiB
PHP
45 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\IsShow;
|
|
use App\Enums\RewardCategory;
|
|
use App\Models\Reward;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
class RewardFactory extends Factory
|
|
{
|
|
protected $model = Reward::class;
|
|
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'name' => $this->faker->words(2, true),
|
|
'points' => $this->faker->numberBetween(10, 500),
|
|
'category' => RewardCategory::REGULAR,
|
|
'is_show' => IsShow::SHOW,
|
|
'start_date' => $this->faker->dateTimeBetween('now', '+1 week')->format('Y-m-d'),
|
|
];
|
|
}
|
|
|
|
public function withStock(int $stock): Factory
|
|
{
|
|
return $this->state(fn () => ['stock' => $stock]);
|
|
}
|
|
|
|
public function withEndDate(string $date): Factory
|
|
{
|
|
return $this->state(fn () => ['end_date' => $date]);
|
|
}
|
|
|
|
public function show(): Factory
|
|
{
|
|
return $this->state(fn () => ['is_show' => IsShow::SHOW]);
|
|
}
|
|
|
|
public function hidden(): Factory
|
|
{
|
|
return $this->state(fn () => ['is_show' => IsShow::HIDDEN]);
|
|
}
|
|
}
|