parfum/database/factories/PointRecordFactory.php

38 lines
905 B
PHP

<?php
namespace Database\Factories;
use App\Enums\PointRecordType;
use App\Models\PointRecord;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class PointRecordFactory extends Factory
{
protected $model = PointRecord::class;
public function definition(): array
{
$change = $this->faker->numberBetween(10, 500);
$isAddition = $this->faker->boolean();
return [
'user_id' => User::factory(),
'change' => $change,
'type' => PointRecordType::REWARD,
'description' => $this->faker->sentence(4),
'is_addition' => true,
];
}
public function reward(): Factory
{
return $this->state(fn () => ['type' => PointRecordType::REWARD]);
}
public function tier(): Factory
{
return $this->state(fn () => ['type' => PointRecordType::TIER]);
}
}