$dto->reportDate, 'period_start' => $dto->periodStart, 'period_end' => $dto->periodEnd, 'rf_department_id' => $dto->rfDepartmentId, ]; $data = [ 'report_date' => $dto->reportDate, 'sent_at' => Carbon::now()->format('Y-m-d H:i:s'), 'period_type' => $dto->periodType, 'period_start' => $dto->periodStart, 'period_end' => $dto->periodEnd, 'status_id' => $dto->statusId, 'rf_lpudoctor_id' => $dto->rfLpuDoctorId, 'rf_department_id' => $dto->rfDepartmentId, 'rf_user_id' => $dto->rfUserId, ]; // Проверяем существование $exists = ReportDuty::where($attributes)->exists(); if ($exists) { // Если существует, обновляем только некоторые поля $updateData = array_diff_key($data, array_flip(['rf_lpudoctor_id', 'rf_user_id'])); $report = ReportDuty::updateOrCreate($attributes, $updateData); } else { $report = ReportDuty::create($data); } return $report; } public function save(\App\Domain\ReportDuty\Models\ReportDuty $reportDuty): ?\App\Domain\ReportDuty\Models\ReportDuty { // TODO: Implement save() method. } public function update(\App\Domain\ReportDuty\Models\ReportDuty $reportDuty): ?\App\Domain\ReportDuty\Models\ReportDuty { // TODO: Implement update() method. } public function findByPeriod(string $startAt, string $endAt): ?\App\Domain\ReportDuty\Models\ReportDuty { // TODO: Implement findByPeriod() method. } public function findByDepartment(int $departmentId): ?\App\Domain\ReportDuty\Models\ReportDuty { // TODO: Implement findByDepartment() method. } public function findByUser(int $userId): ?\App\Domain\ReportDuty\Models\ReportDuty { // TODO: Implement findByUser() method. } public function findById(int $id): ?\App\Domain\ReportDuty\Models\ReportDuty { // TODO: Implement findById() method. } }