In my Symfony project I wrote a query with Doctrine to return one specific result which I will display in my custom array.
I constantly get an error:
Call to a member function getSeats() on null
I tried a bunch of things..
 return $this->createQueryBuilder("e")
        ->where('e.userId =:userId')
        ->setParameter('userId', $user)
        ->getQuery()
        ->getOneOrNullResult();
And in my array..
$reports = [
            'id' => $report['id'],
             ....
            'seats' => is_null($seats->getSeats()) ? 0 : $seats->getSeats()
        ];
I tought the best way to do it is by ternary operator but no luck/
My entity object:
/**
 * @ORM\Column(type="integer", options={"default":0})
 */
protected $seats;
