Beispiel #1
0
 public function imagesAction(Request $request, $id)
 {
     //$images = $this->getImagesAction();
     $em = $this->getDoctrine()->getEntityManager();
     $images = $em->createQueryBuilder()->select('b')->from('RARWebBundle:PropertyImages', 'b')->where('b.property_id = :userId')->setParameter('userId', $id)->getQuery()->getResult();
     /*---- start  - update images of properties  -----*/
     $em = $this->getDoctrine()->getEntityManager();
     $property = $em->getRepository('RARWebBundle:Property')->find($id);
     if (!$property) {
         throw $this->createNotFoundException('Unable to find Blog post.');
     }
     if (is_null($id)) {
         $postData = $request->get('$id');
         $property = $postData['id'];
     }
     $em = $this->getDoctrine()->getEntityManager();
     $property = $em->getRepository('RARWebBundle:Property')->find($id);
     if (!$property) {
         $property = new Property();
         throw $this->createNotFoundException('No product found for idss ' . $id);
     }
     if ($request->getMethod() == 'POST') {
         $file = $_FILES['file']['name'];
         $file1 = $_FILES['file']['tmp_name'];
         move_uploaded_file($_FILES["file"]["tmp_name"], "Property/" . $_FILES["file"]["name"]);
         $propertyName = $this->get('request')->request->get('propertyName');
         $realtor = new PropertyImages();
         $realtor->setPropertyId($id);
         $realtor->setImageUrl($file);
         $em = $this->getDoctrine()->getEntityManager();
         $em->persist($realtor);
         $em->flush();
     }
     /*---- end - Update images of properties  -----*/
     return $this->render('RARAdminBundle:Property:images.html.twig', array('property' => $property, 'images' => $images));
 }
 public function showPropertyImagesAction(Request $request, $id)
 {
     if ($request->getMethod() == 'POST') {
         $file = $_FILES['file']['name'];
         $file1 = $_FILES['file']['tmp_name'];
         move_uploaded_file($_FILES["file"]["tmp_name"], "Property/" . $_FILES["file"]["name"]);
         $realtor = new PropertyImages();
         $realtor->setPropertyId($id);
         $realtor->setImageUrl($file);
         $realtor->setIsMain(0);
         $em = $this->getDoctrine()->getEntityManager();
         $em->persist($realtor);
         $em->flush();
     }
     $em = $this->getDoctrine()->getEntityManager();
     $images = $em->createQueryBuilder()->select('PropertyImages')->from('RARWebBundle:PropertyImages', 'PropertyImages')->leftJoin('RARWebBundle:Property', 'property', "WITH", "property.id=PropertyImages.property_id")->where('property.id = :userId')->setParameter('userId', $id)->getQuery()->getResult();
     $property = $em->getRepository('RARWebBundle:Property')->find($id);
     return $this->render('RARWebBundle:Page:realtorPropertyImages.html.twig', array('images' => $images, 'property' => $property));
 }