Bonjour,
Voila je rencontre un petit problème avec mon code de formulaire de recherche
Ce que je fais
voici mon code indexcontroller.php et RsVoyageRepository.php l'erreur se trouve au niveau du fichier RsVoyageRepository.php
####indexcontroller.php#####
*****Debut******
public function voyage(request $request, RsVoyageRepository $RsVoyageRepository)
{
$results="";
$count=$request->query->count()>0;
if($count)
{
$choix =$request->query->get('radio');
$number =$request->query->get('number');
$villedepart =$request->query->get('Villedepart');
$Villearrivee =$request->query->get('Villearrivee');
$datedepart =$request->query->get('datedepart');
if($choix=="Allerretour"){
$dateretour =$request->query->get('dateretour');
//$results = $this->getDoctrine()->getManager()->getRepository('App:RsVoyage')->findAlleretour($villedepart,$Villearrivee,$datedepart,$dateretour);
$results = $RsVoyageRepository->findAlleretour($villedepart,$Villearrivee,$datedepart,$dateretour);
}
else{
// $results = $this->getDoctrine()->getManager()->getRepository('App:RsVoyage')->findAllersimple($Villedepart,$Villearrivee,$datedepart);
$results = $RsVoyageRepository->findAllersimple($Villedepart,$Villearrivee,$datedepart);
}
}
return $this->render('index/voyage.html.twig',[
'Voyages' => $results
]);
}
*****Fin********
####RsVoyageRepository.php#####
*****Debut******
<?php
namespace App\Repository;
use App\Entity\RsVoyage;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Symfony\Bridge\Doctrine\RegistryInterface;
/**
* @method RsVoyage|null find($id, $lockMode = null, $lockVersion = null)
* @method RsVoyage|null findOneBy(array $criteria, array $orderBy = null)
* @method RsVoyage[] findAll()
* @method RsVoyage[] findAlleretour($Villedepart,$Villearrivee,$datedepart,$dateretour)
* @method RsVoyage[] findAllersimple($Villedepart,$Villearrivee,$datedepart)
* @method RsVoyage[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class RsVoyageRepository extends ServiceEntityRepository
{
public function __construct(RegistryInterface $registry)
{
parent::__construct($registry, RsVoyage::class);
}
/**
* @return RsVoyage[] Returns an array of RsVoyage objects
*/
public function findAlleretour($Villedepart,$Villearrivee,$datedepart,$dateretour)
{
$sql= $this->createQueryBuilder('r')
->andWhere('r.setVilledepart = :val')
->setParameter('val', $villedepart)
;
var_dump($sql);exit();
return $this
->createQueryBuilder('r')
->andWhere('r.setVilledepart = :val')
->setParameter('val', $villedepart)
/*->andWhere('r.setVillearrivee = :val')
->setParameter('val', $Villearrivee)
->andWhere('r.setDate > ?1')
->andWhere('r.setDate < ?2')
->setParameter(1, $datedepart)
->setParameter(2, $dateretour)*/
->getQuery()
->getResult()
;
}
/*
public function findOneBySomeField($value): ?RsVoyage
{
return $this->createQueryBuilder('r')
->andWhere('r.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
/**
* @return RsVoyage[] Returns an array of RsVoyage objects
*/
public function findAllersimple($Villedepart,$Villearrivee,$datedepart):Query
{
return $this->createQueryBuilder('r')
->andWhere('r.setVilledepart = :val')
->setParameter('val', $Villedepart)
->andWhere('r.setVillearrivee = :val')
->setParameter('val', $Villearrivee)
->andWhere('r.setDate = :val')
->setParameter('val', $datedepart)
->getQuery()
->getResult()
;
}
}
*****Fin********
Ce que je veux
Décrivez ici ce que vous cherchez à obtenir
Ce que j'obtiens
Décrivez ici vos erreurs ou ce que vous obtenez à la place de ce que vous attendez :(