35 lines
825 B
PHP
35 lines
825 B
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\PayrollPeriodStatus;
|
|
use App\Models\PayrollPeriod;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends Factory<PayrollPeriod>
|
|
*/
|
|
class PayrollPeriodFactory extends Factory
|
|
{
|
|
public function definition(): array
|
|
{
|
|
$date = fake()->dateTimeBetween('-12 months', 'now');
|
|
|
|
return [
|
|
'year' => (int) $date->format('Y'),
|
|
'month' => (int) $date->format('n'),
|
|
'status' => PayrollPeriodStatus::OPEN->value,
|
|
'closed_at' => null,
|
|
'closed_by_id' => null,
|
|
];
|
|
}
|
|
|
|
public function closed(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'status' => PayrollPeriodStatus::CLOSED->value,
|
|
'closed_at' => now(),
|
|
]);
|
|
}
|
|
}
|