'date:Y-m-d', 'sent_at' => 'datetime:Y-m-d H:i:s', 'period_start' => 'datetime:Y-m-d H:i:s', 'period_end' => 'datetime:Y-m-d H:i:s', ]; public function department() { return $this->belongsTo(Department::class, 'rf_department_id', 'department_id'); } public function patients() { return $this->hasMany(ReportNursePatient::class, 'report_nurse_id'); } public function status() { return $this->belongsTo(ReportStatus::class); } public function doctor() { return $this->belongsTo(MisLpuDoctor::class, 'rf_lpudoctor_id', 'LPUDoctorID'); } public function unwantedEvents() { return $this->hasMany(DutyUnwantedEvent::class, 'report_duty_id', 'id'); } public function getLoadedDepartmentAttribute(int $patientsInDepartment) { $beds = DutyReportMetricResult::where('rf_report_id', $this->id) ->where('rf_metrika_item_id', 1)->pluck('value')->first() ?? 1; return round((($patientsInDepartment ?? 0) * 100) / $beds); } }