public function getAd($id)
 {
     $ad = $this->model->retrieveSingle($id);
     if (isset($ad->category)) {
         $modelCategory = new CategoryModel();
         $category = $modelCategory->getCategory($ad->category);
         $ad->categoryname = $category->name;
     }
     return $ad;
 }
 public function getAction()
 {
     $get = $this->app->request->get(array('id'), array('id' => 'int'));
     if (!$get['success']) {
         unset($get['result']);
         //Show errors
         $this->app->renderJson($get);
         return;
     }
     if ($get['success']) {
         $category = new CategoryModel();
         $this->app->renderJson(array('result' => $category->getCategory($get['result']['id'])) + (array) $get);
     }
 }