I am getting data from database model and want to return in json format, but it returns empty array, but when i use dump for variable that contains objects data then it return the actual data.
Here is the code for getting data from object
$user = $this->getUser();
$bookings = $this->getDoctrine()->getRepository(Trip::class)
->findBy(['customer' => $user], ['id' => 'DESC']);
here i return it in json form
return new JsonResponse(['bookings' => $bookings]);
It display on screen that array is empty.
i use dd to check whether data is comming or not
$user = $this->getUser();
$bookings = $this->getDoctrine()->getRepository(Trip::class)
->findBy(['customer' => $user], ['id' => 'DESC']);
dd($bookings);
It returns
kindly help me out how to overcome this issue