src/Controller/Budget/BudgetController.php line 50

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Budget;
  3. use App\Services\BudgetService;
  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 BudgetController extends AbstractController
  9. {
  10.     public function __construct(private BudgetService $budgetService)
  11.     {
  12.         $this->budgetService $budgetService;
  13.     }
  14.     #[Route('/add-budget'name'app_add_budget'methods: ['POST'])]
  15.     public function add(Request $request): Response
  16.     {
  17.         $data $request->request->all();
  18.         if($data == []){
  19.             $data json_decode($request->getContent(), true);
  20.         }
  21.         return $this->budgetService->add($data);
  22.     }
  23.     #[Route('/delete-budget/{id}'name'app_delete_budget'methods: ['DELETE'])]
  24.     public function delete($id): Response
  25.     {
  26.         return $this->budgetService->delete($id);
  27.     }
  28.     #[Route('/show-budget/{id}'name'app_show_budget'methods: ['GET'])]
  29.     public function show($id): Response
  30.     {
  31.         return $this->budgetService->show($id);
  32.     }
  33.     #[Route('/update-budget/{id}'name'app_update_budget'methods: ['POST'])]
  34.     public function update($idRequest $request): Response
  35.     {
  36.         $data $request->request->all();
  37.         return $this->budgetService->update($id$data);
  38.     }
  39.     #[Route('/get-budgets'name'app_get_budgets'methods: ['GET'])]
  40.     public function getAllBudget(): Response
  41.     {
  42.         return $this->budgetService->getAll();
  43.     }
  44. }