src/Repository/VillesRepository.php line 38

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4.  * @author Raymond
  5.  */
  6. namespace App\Repository;
  7. use App\Entity\Villes;
  8. use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
  9. use Doctrine\ORM\Query;
  10. use Doctrine\Persistence\ManagerRegistry;
  11. class VillesRepository extends ServiceEntityRepository implements iRepository
  12. {
  13.     public function __construct(ManagerRegistry $registry)
  14.     {
  15.         parent::__construct($registryVilles::class);
  16.     }
  17.     
  18.     public function donne_string_noms_villes_principales_dune_localisation($id_localisation$limit=3)
  19.     {
  20.         if ($id_localisation == "33_12_75") {
  21.             return "";
  22.         }
  23.         
  24.         $qb $this->getEntityManager()->createQueryBuilder();
  25.         
  26.         $villes $qb->select([
  27.             'v.nom_ville'
  28.         ])
  29.         ->from('App\Entity\Villes''v')
  30.         ->where('v.code_departement LIKE :id_localisation')->setParameter('id_localisation'$id_localisation.'%')
  31.         ->orderBy('v.population'self::DESC)
  32.         ->setMaxResults($limit)
  33.         ->getQuery()
  34.         ->getResult(Query::HYDRATE_ARRAY);
  35.         
  36.         $string "";
  37.         
  38.         foreach ($villes as $ville) {
  39.             $string .= $ville['nom_ville'] . ', ';
  40.         }
  41.         
  42.         $string trim($string", ");
  43.         
  44.         return $string;
  45.     }
  46.     public function donne_tableau_valorisations_du_secteur($id_annonce)
  47.     {
  48.         $limit 10;
  49.         $qb $this->getEntityManager()->createQueryBuilder();
  50.         $valorisations $qb->select([
  51.             'vlav.id_valorisation',
  52.             'v.titre_valorisation',
  53.             'v.ca_n_affichage AS ca_n',
  54.             'v.date_mois_operation',
  55.             'v.societe_difficulte',
  56.             'v.type_rachat',
  57.             'v.type_acquereur',
  58.             'v.description_publique',
  59.         ])
  60.         ->from('App\Entity\ValorisationsLiensAnnoncesVendeur''vlav')
  61.         ->leftJoin('App\Entity\Valorisations''v'self::WITH'vlav.id_valorisation = v.id_valorisation')
  62.         ->where('vlav.id_annonce = :id_annonce')->setParameter('id_annonce', (int)$id_annonce)
  63.         ->andWhere('v.mode=\'publique\' ')
  64.         ->orderBy('v.date_mois_operation'self::DESC)
  65.         ->setMaxResults($limit)
  66.         ->getQuery()
  67.         ->getResult(Query::HYDRATE_ARRAY);
  68.         return $valorisations;
  69.     }
  70. }