StocksNew/database/seeders/DesignationSeeder.php
Sampanna Rimal 53c0140f58 first commit
2024-08-27 17:48:06 +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);
}
}
}