'boolean', 'sort_order' => 'integer', ]; } public function organization(): BelongsTo { return $this->belongsTo(Organization::class, 'organization_id'); } public function department(): BelongsTo { return $this->belongsTo(Department::class, 'department_id'); } public function beds(): HasMany { return $this->hasMany(Bed::class, 'care_unit_id')->orderBy('sort_order')->orderBy('label'); } public function assignments(): HasMany { return $this->hasMany(StaffAssignment::class, 'care_unit_id'); } public function supportsBeds(): bool { return $this->kind === 'inpatient'; } public function labelForSelect(): string { $dept = $this->relationLoaded('department') ? $this->department : $this->department()->first(); $kindLabel = config('care.care_unit_kinds.'.$this->kind, $this->kind); $base = $this->name.($kindLabel ? ' ('.$kindLabel.')' : ''); if ($dept?->name) { return $dept->name.' — '.$base; } return $base; } }