- menyesuaikan model jika ada yang salah seperti kurangnya trait SoftDeletes, casting yang salah, relasi yang kurang dan lainnya - memperbaiki enum di migrasi
34 lines
855 B
PHP
34 lines
855 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' => SalaryAdjustmentType::BONUS,
|
|
'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]);
|
|
}
|
|
}
|