src/Controller/CookingEvents/CookingEventsController.php line 51

Open in your IDE?
  1. <?php
  2. namespace App\Controller\CookingEvents;
  3. use App\Services\CookingEventService;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. class CookingEventsController extends AbstractController
  9. {
  10.     public function __construct(private CookingEventService $cookingEventService)
  11.     {
  12.     }
  13.     #[Route('/api/add-cooking_event'name'add_cooking_event'methods: ['POST'])]
  14.     public function add(Request $request): Response
  15.     {
  16.         $file $request->files->get('photoCouverture');
  17.         $data $request->request->all();
  18.         if ($data == []) {
  19.             $data json_decode($request->getContent(), true);
  20.         }
  21.         return $this->cookingEventService->add($data$file);
  22.     }
  23.     #[Route('/api/delete-cooking_event/{id}'name'delete_cooking_event'methods: ['DELETE'])]
  24.     public function delete($id): Response
  25.     {
  26.         return $this->cookingEventService->delete($id);
  27.     }
  28.     #[Route('/show-cooking_event/{id}'name'show_cooking_event'methods: ['GET'])]
  29.     public function show($id): Response
  30.     {
  31.         return $this->cookingEventService->show($id);
  32.     }
  33.     #[Route('/update-cooking_event/{id}'name'app_cooking_event'methods: ['PATCH'])]
  34.     public function update($idRequest $request): Response
  35.     {
  36.         $data $request->request->all();
  37.         return $this->cookingEventService->update($id$data);
  38.     }
  39.     #[Route('get-cooking_events'name'cooking_events'methods: ["GET"])]
  40.     public function getAll()
  41.     {
  42.         return $this->cookingEventService->getAll();
  43.     }
  44. }