New API - RoomCategory

This commit is contained in:
2024-04-22 18:10:16 +02:00
parent 2079188760
commit fcfe2f9250
12 changed files with 1085 additions and 3 deletions
+34
View File
@@ -0,0 +1,34 @@
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Doctrine\ORM\EntityManagerInterface;
use App\Repository\RoomCategoryRepository;
use App\Entity\RoomCategory;
use App\Entity\RoomCategoryDetails;
use App\Entity\RoomCategoryPhoto;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Serializer\Context\Normalizer\ObjectNormalizerContextBuilder;
class RoomCategoryController extends AbstractController
{
#[Route('/room/category', name: 'app_room_category')]
public function getAll(RoomCategoryRepository $catRepo, SerializerInterface $serializer): Response
{
$catList = $catRepo->findAll();
return $this->json(["results" => $catList]);
}
#[Route('/room/category/{id}', name: 'app_room_category')]
public function getById(RoomCategory $category, SerializerInterface $serializer): Response
{
return $this->json($category);
}
}