public function filterCostNgAction(Request $request) { $em = $this->getDoctrine()->getManager(); $response = new Response(json_encode(array("result" => Cost::filterCosts($em, $request->query->all(), true)))); $response->headers->set('Content-Type', 'application/json'); return $response; }
public static function addCost($em, $parameters) { $costCategory = $em->getRepository("RenovateMainBundle:CostCategory")->find($parameters->categoryid); $cost = new Cost(); $cost->setCategoryid($costCategory->getId()); $cost->setCategory($costCategory); $cost->setName($parameters->name); $cost->setUnits($parameters->units); $cost->setPrice($parameters->price); $em->persist($cost); $em->flush(); return $cost; }
public static function removeCostCategoryById($em, $id) { $costCategory = $em->getRepository("RenovateMainBundle:CostCategory")->find($id); foreach ($costCategory->getCosts() as $cost) { Cost::removeCostById($em, $cost->getId()); } $em->remove($costCategory); $em->flush(); return true; }