Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.23 KB | None | 0 0
  1. public function getAction($id) {
  2.         $em = $this->getDoctrine()->getManager();
  3.  
  4.         $achievement = $em->getRepository('BlogBundle:Achievements')->find($id);
  5.         $achievementid = $achievement->getId();
  6.         $user = $this->getUser()->getId();
  7.         $userpoint = $this->getUser()->getpoints();
  8.         $userid = $this->getUser()->getId();
  9.         $points = $achievement->getpoints();
  10.  
  11.  
  12.         if($userpoint >= $points) {
  13.  
  14.            $category = $this->getUser();
  15.  
  16.             $product = $em->getRepository('BlogBundle:Achievements')->find($id);
  17.  
  18.             // relate this product to the category
  19.             // Pobiera achievements
  20.             $product->getId();
  21.             // Pobiera użytkownika
  22.             $category->getId();
  23.  
  24.             $em = $this->getDoctrine()->getManager();
  25.             $em->persist($product);
  26.             $em->persist($category);
  27.             $em->flush();
  28.  
  29.             return new Response(
  30.                 'Saved new product with id: '.$product->getId()
  31.                 .' and new category with id: '.$category->getId()
  32.             );
  33.         }
  34.  
  35.  
  36.         return $this->render('BlogBundle:Achievements:get.html.twig', array(
  37.             'pokaz' => $userpoint
  38.         ));
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement