Skip to content

Commit

Permalink
fix change status for projects
Browse files Browse the repository at this point in the history
  • Loading branch information
gheorghelupu17 committed Oct 12, 2023
1 parent e65989a commit 2801a01
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/Services/ProjectService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}
Expand Down

0 comments on commit 2801a01

Please sign in to comment.