src/Controller/ReservationListingController.php line 34
<?phpnamespace App\Controller;use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;use Symfony\Component\HttpFoundation\Response;use Symfony\Component\HttpFoundation\Request;use Symfony\Component\Routing\Annotation\Route;use App\Entity\Reservation;use App\Service\GuestyConnector;use Doctrine\Persistence\ManagerRegistry;use Psr\Log\LoggerInterface;class ReservationListingController extends AbstractController{protected ManagerRegistry $doctrine;protected Request $request;protected LoggerInterface $logger;private \Doctrine\Persistence\ObjectRepository $repository;public function __construct(ManagerRegistry $doctrine,LoggerInterface $logger){$this->doctrine = $doctrine;$this->logger = $logger;$this->repository= $this->doctrine->getRepository(Reservation::class);}#[Route('/reservation/listing', name: 'app_reservation_listing')]public function index(Request $request): Response{$this->request = $request;$type = $this->request->query->get('type');$data = $this->retreiveFromDb($type);return $this->render('reservation_listing/index.html.twig', ['controller_name' => 'ReservationListingController','data' => $data,'judete' => Reservation::COUNTIES,'sectoare' => Reservation::SECTORS,'type'=>$type ??'Upcoming']);}public function retreiveFromDb( $type = 'upcoming'){switch ($type){case 'single':$id =$this->request->query->get('guesty_id');$result = [$this->repository->findOneBy(['guesty_id'=>$id])];break;case 'invoicing_today':$result = $this->repository->getInvoicingToday();break;case 'pending':// pending$result = $this->repository->getPending();break;case 'pending2':// pending$result = $this->repository->getByFlow('pending');break;case 'upcoming2':// pending$result = $this->repository->getByFlow('upcoming');break;case 'past':$result = $this->repository->getPast();break;case 'currentmonth':$result = $this->repository->getCurrentMonth();break;case 'lastmonth':$result = $this->repository->getLastMonth();break;case 'last2months':$result = $this->repository->getLast2Months();break;case 'invoiced':$result = $this->repository->getInvoiced();break;case 'canceled':$result = $this->repository->getCanceled();break;case 'needsaddress':$result = $this->repository->getNeedsAddress();break;case 'filter':$checkoutFrom=$this->request->get('checkoutfrom');$checkoutUntil=$this->request->get('checkoutuntil');$invoiceableOnly=$this->request->get('invoiceableonly');$notinvoicedonly=$this->request->get('notinvoicedonly');$fulladdressonly=$this->request->get('fulladdressonly');$params = ['checkoutfrom' =>$checkoutFrom,'checkoutuntil' =>$checkoutUntil,'invoiceableonly' =>$invoiceableOnly,'notinvoicedonly' => $notinvoicedonly,'fulladdressonly' => $fulladdressonly];$result = $this->repository->getFiltered($params);break;case 'all':$result = $this->repository->findAll();break;case 'upcoming_invoices':$result = $this->repository->getUpcomingInvoices();break;case 'ongoing':$result = $this->repository->getOngoing();break;case 'upcoming':default:$result = $this->repository->getUpcomingReservations();break;}return $result;}}