- menyesuaikan model jika ada yang salah seperti kurangnya trait SoftDeletes, casting yang salah, relasi yang kurang dan lainnya - memperbaiki enum di migrasi
26 lines
619 B
PHP
26 lines
619 B
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\SalaryHistory;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
class SalaryHistoryFactory extends Factory
|
|
{
|
|
protected $model = SalaryHistory::class;
|
|
|
|
public function definition(): array
|
|
{
|
|
$old = $this->faker->numberBetween(3000000, 6000000);
|
|
$new = $old + $this->faker->numberBetween(-500000, 1000000);
|
|
|
|
return [
|
|
'user_id' => User::factory(),
|
|
'old_salary' => $old,
|
|
'new_salary' => max(0, $new),
|
|
'effective_date' => $this->faker->date(),
|
|
];
|
|
}
|
|
}
|