diff --git a/api/src/Controller/FruitController.php b/api/src/Controller/FruitController.php index a94e1bb..a6a8c7b 100644 --- a/api/src/Controller/FruitController.php +++ b/api/src/Controller/FruitController.php @@ -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 @@ -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 ]); }