SHARE
TWEET

Untitled

a guest Feb 18th, 2020 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  public function likeBlogAction($id)
  2.     {
  3.         $user = $this->getUser();
  4.         if ($user == null) {
  5.             return $this->redirectToRoute('fos_user_security_login');
  6.         }
  7.         $em = $this->getDoctrine()->getManager();
  8.         $post = $em->getRepository('BlogBundle:Blog')->find($id);
  9.  
  10.         $love = new BlogLike();
  11.  
  12.         $love->setUser($user);
  13.         $post->setLikesnumber($post->getLikesnumber() + 1);
  14.         $love->setBlog($post);
  15.         $em->persist($love);
  16.         $em->flush();
  17.  
  18.         return $this->redirectToRoute('blog_show', array('id' => $post->getId()));
  19.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top