Exception detected!

Error: Call to a member function setNbViews() on null

500 Internal Server Error - FatalErrorException

Stack Trace

  1. in src/Offers/OffersBundle/Controller/OffersController.php at line 187  -
    1.         $offer $em->getRepository('OffersBundle:Offers')->findOneBy(array('slug' => $slug));
    2.         $post $em->getRepository('PostBundle:Post')->findBy(array(), array('id' => 'DESC'), 40);
    3.             
    4.             $offer->setNbViews($offer->getNbViews()+1);
    5.             $em->flush();
    6.         if (!$offer) throw $this->createNotFoundException('Le offer n\'existe pas.');

Logs  -

Stack Trace (Plain Text)  +