Skip to content

Commit

Permalink
feat: added status type when adding to favorites
Browse files Browse the repository at this point in the history
  • Loading branch information
benborla committed Nov 18, 2023
1 parent 7703e5d commit 6b64c42
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/src/Controller/FruitController.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ public function addToFavorite(

$id = (int) $request->attributes->get('id');
$fruit = $fruits->find($id);
$status = 'existing';

// @INFO: Throw a 404 if a resource is not found
// @INFO: Ensure that request method is POST
Expand All @@ -178,11 +179,13 @@ public function addToFavorite(

$this->em->persist($favorite);
$this->em->flush();
$status = 'new';
}

return $this->json([
'fruit' => $favorite->getFruit()->toArray(),
'date_added' => $favorite->getDateAdded(),
'status' => $status
]);
}

Expand Down

0 comments on commit 6b64c42

Please sign in to comment.