src/Controller/Restaurant/RestaurantController.php line 63

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Restaurant;
  3. use App\Services\RestaurantService;
  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 RestaurantController extends AbstractController
  9. {
  10.     private $restoService;
  11.     public function __construct(RestaurantService $restoService)
  12.     {
  13.         $this->restoService $restoService;
  14.     }
  15.     #[Route('/api/add-restaurant'name'app_restaurant'methods: ["POST"])]
  16.     public function addRestaurant(Request $request): Response
  17.     {
  18.         $data $request->request->all();
  19.         $files $request->files;
  20.         return $this->restoService->add($data$files);
  21.     }
  22.     #[Route('/api/delete-restaurant/{id}'name'delete_restaurant'methods: ["DELETE"])]
  23.     public function deleteRestaurant($id): Response
  24.     {
  25.         return $this->restoService->delete($id);
  26.     }
  27.     #[Route('/admin/delete-restaurant/{id}'name'delete_restaurant_admin'methods: ["DELETE"])]
  28.     public function deleteRestaurantAdmin($id): Response
  29.     {
  30.         return $this->restoService->delete($id);
  31.     }
  32.     #[Route('/show-restaurant/{slug}'name'show_restaurant'methods: ["GET"])]
  33.     public function showRestaurant($slug): Response
  34.     {
  35.         return $this->restoService->show($slug);
  36.     }
  37.     #[Route('get-restaurant-spotlight'name'get_restaurant_spotlight'methods: ["GET"])]
  38.     public function getRestaurantSpotLight(): Response
  39.     {
  40.         return $this->restoService->spotLight();
  41.     }
  42.     #[Route('/api/update-restaurant/{id}'name'update_restaurant'methods: ["POST"])]
  43.     public function updateRestaurant($idRequest $request): Response
  44.     {
  45.         $data $request->request->all();
  46.         $files $request->files;
  47.             
  48.         return $this->restoService->update($id$data$files);
  49.     }
  50.     #[Route('/get-restaurants'name'get_restaurant'methods: ["POST"])]
  51.     public function getRestaurant(Request $request): Response
  52.     {
  53.         $data json_decode($request->getContent(), true);
  54.         return $this->restoService->getAll($data);
  55.     } 
  56.     #[Route('/add-dish'name'app_add_dish'methods: ["POST"])]
  57.     public function addDish(Request $request): Response
  58.     {
  59.         $data $request->request->all();
  60.         $files $request->files->get('image_url');         
  61.         return $this->restoService->addDish($data$files);
  62.     }
  63.     #[Route('/get-dishes'name'app_get_dishs'methods: ["GET"])]
  64.     public function getDishes(): Response
  65.     {
  66.         return $this->restoService->getDishes();
  67.     }
  68.     #[Route('/show-dish/{id}'name'app_get_dish_show'methods: ["GET"])]
  69.     public function showDish($id): Response
  70.     {
  71.         return $this->restoService->showDish($id);
  72.     }
  73.     #[Route('/api/disabled-dish/{id}'name'app_disabled_dish'methods: ["PATCH"])]
  74.     public function disabledDish($id): Response
  75.     {
  76.         return $this->restoService->disabledDish($id);
  77.     }
  78.     #[Route('/api/update-dish/{id}'name'app_get_dish_update'methods: ["POST"])]
  79.     public function updateDish($id,Request $request): Response
  80.     {
  81.         $data $request->request->all();        
  82.         
  83.         $files $request->files->get('image_url');
  84.         return $this->restoService->updateDish($id,$data$files);
  85.     }
  86.     #[Route('/get-dishes_by_type/{id}/{resto_id}'name'app_get_dishes_by_types'methods: ["GET"])]
  87.     public function getDishByType($id$resto_id): Response
  88.     {
  89.         return $this->restoService->getDishesByType($id$resto_id);
  90.     }
  91.     #[Route('/api/delete-dish/{id}'name'app_delete_dish'methods: ["DELETE"])]
  92.     public function deleteDish($id): Response
  93.     {
  94.         return $this->restoService->deleteDish($id);
  95.     }
  96.     #[Route('search-restaurant-by-name/{keyword}')]
  97.     public function getRestaurantByName($keyword){
  98.         return $this->restoService->getRestoByName($keyword);    
  99.     }
  100.     #[Route('/api/get-resto-orders/{id}')]
  101.     public function getRestoOrders($id){
  102.         return $this->restoService->getRestoOrders($id);    
  103.     }
  104.     #[Route('get-all-restaurants'name"all_resto",methods:["GET"])]
  105.     public function getAllResto(){
  106.         return $this->restoService->getAllRestoForDash();    
  107.     }
  108.    
  109.     #[Route('active-or-desactive-restaurant/{id}'name"change_resto_status",methods:["GET"])]
  110.     public function activeOrDesactive($id){
  111.         return $this->restoService->activeOrDesactive($id);    
  112.     }
  113. }