lundi 20 mai 2019

I have joined two tables (Policy and Vehicle) in a one to one relationship. I want to get records from vehicle where vehicle.policy is null

I am creating a Form form Policy where i want show those vehicles are not already used or associated with policy since its a one to one relation ship, and i am using query_builder for this purpose but i am not getting filtered results.

$form = $this->createFormBuilder($policy)
    ->add('vehicle', EntityType::class,[
          'class'=>Vehicle::class,
          'label' => 'Vehicle Plate',
          'query_builder' => function (VehicleRepository $vr){
                 ->andWhere('vehicle.policy IS NULL');
           }])

But i am getting this error

A single-valued association path expression to an inverse side is not supported in DQL queries. Instead of "vehicle.policy" use an explicit join.




Aucun commentaire:

Enregistrer un commentaire