Heera/database/seeders/DesignationSeeder.php
2024-05-16 09:31:08 +05:45

63 lines
1.5 KiB
PHP

<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Modules\Admin\Models\Department;
use Modules\Admin\Models\Designation;
class DesignationSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$designations = [
[
'name' => "Manager",
'department_name' => 'HR'
],
[
'name' => "Analyst",
'department_name' => 'Marketing'
],
[
'name' => "HR Specialist",
'department_name' => 'HR'
],
[
'name' => "Sales Representative",
'department_name' => "Marketing"
],
[
'name' => "Full Stack",
'department_name' => "IT"
],
[
'name' => "Backend",
'department_name' => "IT"
],
];
foreach ($designations as $designation) {
$department = Department::where('name', $designation['department_name'])->first();
if ($department) {
$designationData = [
'department_id' => $department->department_id,
'name' => $designation['name']
];
}
Designation::create($designationData);
}
}
}