51 lines
1.4 KiB
PHP
51 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\EmployeeAdvanceStatus;
|
|
use App\Models\Employee;
|
|
use App\Models\EmployeeAdvance;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends Factory<EmployeeAdvance>
|
|
*/
|
|
class EmployeeAdvanceFactory extends Factory
|
|
{
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'employee_id' => Employee::factory(),
|
|
'amount' => fake()->numberBetween(100_000, 3_000_000),
|
|
'description' => fake()->sentence(3),
|
|
'due_date' => fake()->dateTimeBetween('now', '+3 months'),
|
|
'status' => EmployeeAdvanceStatus::PENDING->value,
|
|
'cash_transaction_id' => null,
|
|
'repayment_cash_transaction_id' => null,
|
|
'verified_at' => null,
|
|
'verified_by_id' => null,
|
|
'paid_at' => null,
|
|
'paid_by_id' => null,
|
|
];
|
|
}
|
|
|
|
public function approved(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'status' => EmployeeAdvanceStatus::APPROVED->value,
|
|
'verified_at' => now(),
|
|
'verified_by_id' => User::factory(),
|
|
]);
|
|
}
|
|
|
|
public function rejected(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'status' => EmployeeAdvanceStatus::REJECTED->value,
|
|
'verified_at' => now(),
|
|
'verified_by_id' => User::factory(),
|
|
]);
|
|
}
|
|
}
|