Files
hr/database/seeders/DepartmentSeeder.php
2026-07-30 17:24:40 +05:00

57 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace Database\Seeders;
use App\Models\Department;
use Illuminate\Database\Seeder;
class DepartmentSeeder extends Seeder
{
/**
* @var array<string, array{name: string, code: string, description: string}>
*/
private const DEPARTMENTS = [
'production' => [
'name' => 'Production',
'code' => 'PROD',
'description' => 'Manufacturing and production operations.',
],
'warehouse' => [
'name' => 'Warehouse',
'code' => 'WH',
'description' => 'Inventory and logistics.',
],
'administration' => [
'name' => 'Administration',
'code' => 'ADM',
'description' => 'General administration and office management.',
],
'hr' => [
'name' => 'HR',
'code' => 'HR',
'description' => 'Human resources and personnel management.',
],
'accounting' => [
'name' => 'Accounting',
'code' => 'ACC',
'description' => 'Finance and accounting.',
],
];
public function run(): void
{
foreach (self::DEPARTMENTS as $department) {
Department::query()->updateOrCreate(
['code' => $department['code']],
[
'name' => $department['name'],
'description' => $department['description'],
'is_active' => true,
],
);
}
}
}