first commit
This commit is contained in:
44
database/factories/ReportingCycleFactory.php
Normal file
44
database/factories/ReportingCycleFactory.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?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)]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user