public function getCategoriesWithCount()
 {
     $ordering = CPS_StringOrdering('name', 'en', 'ascending');
     $documents = $this->model->search('*', null, null, array('post' => 'no'), $ordering);
     $ad = new AdModel();
     $result = array();
     foreach ($documents as $id => $document) {
         $document->count = $ad->countAdsByCategory($document->id);
         $result[] = $document;
     }
     return $result;
 }
Exemplo n.º 2
0
 public function searchAction()
 {
     $get = $this->app->request->get(array('searchTerm'), array('searchTerm' => 'required'));
     if (!$get['success']) {
         unset($get['result']);
         //Show errors
         $this->app->renderJson($get);
         return;
     }
     if ($get['success']) {
         $ad = new AdModel();
         $this->app->renderJson(array('result' => $ad->Search($get['result']['searchTerm'])) + (array) $get);
     }
 }