From 2801a01af4d96374eab22091d8c1a4f107aa9bf1 Mon Sep 17 00:00:00 2001 From: Lupu Gheorghe Date: Thu, 12 Oct 2023 16:31:19 +0300 Subject: [PATCH] fix change status for projects --- app/Services/ProjectService.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/Services/ProjectService.php b/app/Services/ProjectService.php index 24ca9ae0..dca3a7a9 100644 --- a/app/Services/ProjectService.php +++ b/app/Services/ProjectService.php @@ -78,10 +78,7 @@ private function createPendingProject(array $data): Project|RegionalProject public function changeStatus($id, string $status): void { $this->project = $this->project::findOrFail($id); - match ($status) { - ProjectStatus::draft->value => $this->project->update(['status' => $status]), - ProjectStatus::pending->value => $this->createPendingProject($this->project->toArray()), - }; + if ($this->project->status === ProjectStatus::draft && $status === ProjectStatus::pending->value) { $fields = $this->project->toArray(); $requiredFields = $this->project->getRequiredFieldsForApproval(); @@ -95,7 +92,9 @@ public function changeStatus($id, string $status): void throw new ('Project is missing required fields for approval, please fill in all required fields . Please fill: ' . implode(', ', $missingFields)); } } - $this->project->update(['status' => $status]); + $this->project->status = ProjectStatus::pending->value; + $this->project->save(); +// dd($this->project); if ($status === ProjectStatus::approved->value) { $this->sendCreateNotifications($this->project); }