<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\LepDiiaServiceOnline;
class ServicesListController extends AbstractController
{
#[Route('/services', name: 'app_services_list')]
public function index(EntityManagerInterface $entityManager): Response
{
$data = array();
$data['controller_name'] = 'ServicesListController';
$data['version'] = rand(10, 1000);
$data['type'] = '';
$repository = $entityManager->getRepository(LepDiiaServiceOnline::class);
$service = $repository->findAll();
$i = 0;
foreach($service as $item){
$data['rows'][$i]['name'] = $item->getNameService();
$data['rows'][$i]['synonym'] = $item->getSynonym();
$i ++;
}
if ($i == 0){
$data['rows'][$i]['name'] = '';
$data['rows'][$i]['synonym'] = '';
}
return $this->render('services_list/index.html.twig', $data);
}
#[Route('/services/clients', name: 'app_services_list_clients')]
public function clients(EntityManagerInterface $entityManager): Response
{
$data = array();
$data['controller_name'] = 'ServicesListController';
$data['version'] = rand(10, 1000);
$data['type'] = ' для побутових споживачів';
$repository = $entityManager->getRepository(LepDiiaServiceOnline::class);
$service = $repository->findBy(['typeService' => 'pobut']);
$i = 0;
foreach($service as $item){
$data['rows'][$i]['name'] = $item->getNameService();
$data['rows'][$i]['synonym'] = $item->getSynonym();
$i ++;
}
if ($i == 0){
$data['rows'][$i]['name'] = '';
$data['rows'][$i]['synonym'] = '';
}
return $this->render('services_list/index.html.twig', $data);
}
#[Route('/services/company', name: 'app_services_list_company')]
public function company(EntityManagerInterface $entityManager): Response
{
$data = array();
$data['controller_name'] = 'ServicesListController';
$data['version'] = rand(10, 1000);
$data['type'] = ' для непобутових споживачів';
$repository = $entityManager->getRepository(LepDiiaServiceOnline::class);
$service = $repository->findBy(['typeService' => 'zbut']);
$i = 0;
foreach($service as $item){
$data['rows'][$i]['name'] = $item->getNameService();
$data['rows'][$i]['synonym'] = $item->getSynonym();
$i ++;
}
$service = $repository->findBy(['typeService' => 'business']);
foreach($service as $item){
$data['rows'][$i]['name'] = $item->getNameService();
$data['rows'][$i]['synonym'] = $item->getSynonym();
$i ++;
}
if ($i == 0){
$data['rows'][$i]['name'] = '';
$data['rows'][$i]['synonym'] = '';
}
return $this->render('services_list/index.html.twig', $data);
}
}