Error: Call to a member function setNbViews() on null
500 Internal Server Error - FatalErrorException
Stack Trace
-
in src/Offers/OffersBundle/Controller/OffersController.php at line 187
$offer = $em->getRepository('OffersBundle:Offers')->findOneBy(array('slug' => $slug));
$post = $em->getRepository('PostBundle:Post')->findBy(array(), array('id' => 'DESC'), 4, 0);
$offer->setNbViews($offer->getNbViews()+1);
$em->flush();
if (!$offer) throw $this->createNotFoundException('Le offer n\'existe pas.');