I'm setting up an advanced search for a jobboard and I need to find resumes by contract, knowing that a resume can have multiple contracts.
I have a form where you can choose which type of contract you are looking for (It's a ChoiceType::class with multiple => true)
In my table, my colomn contract :
In my Entity Resume :
/**
* @ORM\Column(type="array", nullable=true)
*/
private $contract = [];
public function getContract(): ?array
{
return $this->contract;
}
public function setContract(?array $contract): self
{
$this->contract = $contract;
return $this;
}
In my repository :
public function findByContract(array $contract)
{
return $this->createQueryBuilder('r')
->andWhere('r.contract IN (:cons)')
->setParameter('cons', $contract)
->getQuery()
->getResult()
;
}
In my controller :
public function index(Request $request, ResumeRepository $resumeRepository)
{
$formSearch = $this->createForm(ResumeSearchFormType::class);
$formSearch->handleRequest($request);
if ($formSearch->isSubmitted() && $formSearch->isValid()) {
$data = $formSearch->getData();
$results = $resumeRepository->findByContract($data->getContract());
var_dump($results); die;
This var_dump() returns an empty array.
I don't know how I can do to find resume by contract