first commit
Some checks failed
tests / ci (8.5) (push) Has been cancelled
linter / quality (push) Has been cancelled
tests / ci (8.3) (push) Has been cancelled
tests / ci (8.4) (push) Has been cancelled

This commit is contained in:
brusnitsyn
2026-04-03 17:20:05 +09:00
commit 3edc8e667e
358 changed files with 39258 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
<?php
namespace Database\Seeders;
use App\Models\Department;
use App\Models\HospitalUnit;
use Illuminate\Database\Seeder;
use Illuminate\Support\Str;
class DepartmentSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$departmentUnitMap = collect(config('medical-report.hospital_department_unit_map', []))
->filter(fn (mixed $value, mixed $key): bool => is_string($key) && $key !== '' && is_string($value) && $value !== '');
collect(config('medical-report.hospital_departments', []))
->filter(fn (mixed $name): bool => is_string($name) && trim($name) !== '')
->each(function (string $name) use ($departmentUnitMap): void {
$hospitalUnitId = null;
$mappedUnitName = $departmentUnitMap->get($name);
if (is_string($mappedUnitName) && $mappedUnitName !== '') {
$hospitalUnitId = HospitalUnit::query()
->where('name', $mappedUnitName)
->value('id');
}
Department::query()->updateOrCreate(
['code' => Str::slug(Str::ascii($name))],
[
'name' => $name,
'hospital_unit_id' => $hospitalUnitId,
'is_active' => true,
],
);
});
}
}