44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\Budget;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
class BudgetFactory extends Factory
|
|
{
|
|
protected $model = Budget::class;
|
|
|
|
public function definition(): array
|
|
{
|
|
$start = now()->startOfYear();
|
|
|
|
return [
|
|
'fiscal_year' => now()->year,
|
|
'name' => $this->faker->sentence(3),
|
|
'period_type' => 'annual',
|
|
'period_start' => $start,
|
|
'period_end' => $start->copy()->endOfYear(),
|
|
'status' => Budget::STATUS_DRAFT,
|
|
'created_by_user_id' => User::factory(),
|
|
'approved_by_user_id' => null,
|
|
'approved_at' => null,
|
|
'notes' => $this->faker->sentence(),
|
|
];
|
|
}
|
|
|
|
public function submitted(): static
|
|
{
|
|
return $this->state(fn () => ['status' => Budget::STATUS_SUBMITTED]);
|
|
}
|
|
|
|
public function approved(): static
|
|
{
|
|
return $this->state(fn () => [
|
|
'status' => Budget::STATUS_APPROVED,
|
|
'approved_at' => now(),
|
|
]);
|
|
}
|
|
}
|