migrate to gtea from bistbucket
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\HRM\Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Modules\HRM\Models\Employee;
|
||||
use Modules\HRM\Models\SalarySetup;
|
||||
use Modules\HRM\Models\SalaryType;
|
||||
|
||||
class SalarySetupsTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$restaurantId = 1;
|
||||
|
||||
$users = Employee::where('restaurant_id', $restaurantId)->pluck('id')->toArray();
|
||||
$salaryTypes = SalaryType::where('restaurant_id', $restaurantId)->pluck('id')->toArray();
|
||||
if (empty($users) || empty($salaryTypes)) {
|
||||
$this->command->info('Please seed Employees and SalaryTypes first.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($users as $employeeId) {
|
||||
foreach ($salaryTypes as $typeId) {
|
||||
SalarySetup::updateOrCreate(
|
||||
[
|
||||
'employee_id' => $employeeId,
|
||||
'salary_type_id' => $typeId,
|
||||
'restaurant_id' => $restaurantId,
|
||||
],
|
||||
[
|
||||
'amount' => rand(1000, 5000),
|
||||
'calculation_type' => 'fixed',
|
||||
'status' => 1,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->command->info('Salary setups seeded successfully.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user