44 lines
1.4 KiB
PHP
44 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Modules\HRM\Database\Seeders;
|
|
|
|
use Illuminate\Database\Seeder;
|
|
use Modules\HRM\Models\Employee;
|
|
use Modules\HRM\Models\EmployeeSalary;
|
|
|
|
class EmployeeSalariesTableSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
$users = Employee::all();
|
|
foreach ($users as $employee) {
|
|
$basic = rand(20000, 50000);
|
|
$allowances = rand(1000, 5000);
|
|
$deductions = rand(500, 2000);
|
|
$overtimeHours = rand(0, 20);
|
|
$overtimeRate = rand(200, 500);
|
|
$bonus = rand(0, 5000);
|
|
$netSalary = $basic + $allowances + ($overtimeHours * $overtimeRate) + $bonus - $deductions;
|
|
|
|
EmployeeSalary::create([
|
|
'restaurant_id' => $employee->restaurant_id,
|
|
'employee_id' => $employee->id,
|
|
'salary_month' => now()->format('Y-m'),
|
|
'basic_salary' => $basic,
|
|
'allowances' => $allowances,
|
|
'deductions' => $deductions,
|
|
'overtime_hours' => $overtimeHours,
|
|
'overtime_rate' => $overtimeRate,
|
|
'bonus' => $bonus,
|
|
'net_salary' => $netSalary,
|
|
'payment_date' => now(),
|
|
'remarks' => 'Auto-generated seeder',
|
|
'status' => 'paid',
|
|
]);
|
|
}
|
|
}
|
|
}
|