45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\ReportingCycle;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
class ReportingCycleFactory extends Factory
|
|
{
|
|
protected $model = ReportingCycle::class;
|
|
|
|
public function definition(): array
|
|
{
|
|
$renewalYear = fake()->numberBetween(2026, 2035);
|
|
$reportingYear = $renewalYear - 2;
|
|
|
|
return [
|
|
'renewal_year' => $renewalYear,
|
|
'reporting_year' => $reportingYear,
|
|
'period_start' => Carbon::create($reportingYear, 1, 1),
|
|
'period_end' => Carbon::create($reportingYear, 12, 31),
|
|
'cut_off_date' => Carbon::create($renewalYear - 1, 12, 1),
|
|
'licence_period_year' => 1,
|
|
'status' => 'aktif',
|
|
];
|
|
}
|
|
|
|
public function renewalYear(int $year): static
|
|
{
|
|
return $this->state(fn () => [
|
|
'renewal_year' => $year,
|
|
'reporting_year' => $year - 2,
|
|
'period_start' => Carbon::create($year - 2, 1, 1),
|
|
'period_end' => Carbon::create($year - 2, 12, 31),
|
|
'cut_off_date' => Carbon::create($year - 1, 12, 1),
|
|
]);
|
|
}
|
|
|
|
public function overdue(): static
|
|
{
|
|
return $this->state(fn () => ['cut_off_date' => now()->subDays(5)]);
|
|
}
|
|
}
|