parfum/database/factories/PayrollAdjustmentFactory.php

34 lines
886 B
PHP

<?php
namespace Database\Factories;
use App\Enums\SalaryAdjustmentType;
use App\Models\Payroll;
use App\Models\PayrollAdjustment;
use Illuminate\Database\Eloquent\Factories\Factory;
class PayrollAdjustmentFactory extends Factory
{
protected $model = PayrollAdjustment::class;
public function definition(): array
{
return [
'payroll_id' => Payroll::factory(),
'type' => $this->faker->randomElement(SalaryAdjustmentType::cases()),
'description' => $this->faker->sentence(4),
'amount' => $this->faker->numberBetween(50000, 500000),
];
}
public function deduction(): Factory
{
return $this->state(fn () => ['type' => SalaryAdjustmentType::DEDUCTION]);
}
public function bonus(): Factory
{
return $this->state(fn () => ['type' => SalaryAdjustmentType::BONUS]);
}
}