示例#1
0
 public function handleRemoveImage($image_id, $item_id, $module)
 {
     Galleries::removeImageByModule($image_id, $item_id, $module);
 }
示例#2
0
 public function fetchAllEx($page = 1, $limit = 15, $orderBy = '', $sort = '', $filters = '')
 {
     //$filters = $this->prepareFilter($filters);
     //dump($filters);
     $offset = ($page - 1) * $limit;
     $res = dibi::select('*')->from('subjects_all')->as('s');
     if (isset($filters['category']) && $filters['category']) {
         $res->leftJoin('[subject_x_category] as [sc]')->on('sc.subject_id', '=', 's.id');
         $res->where('[sc.category_id] in %l', $filters['category']);
     }
     if (isset($filters['kids']) && $filters['kids'] == 1) {
         $res->where('[age_max] <= 3');
     }
     if (isset($filters['kids']) && $filters['kids'] == 2) {
         $res->where('[age_min] > 3');
         $res->where('[age_max] <= 6');
     }
     if (isset($filters['kids']) && $filters['kids'] == 3) {
         $res->where('[age_min] > 6');
     }
     if (isset($filters['stroller']) && $filters['stroller']) {
         $res->where('[s.stroller] = 1');
     }
     if (isset($filters['locality']) && $filters['locality']) {
         $res->where('[s.locality_id] = %i', $filters['locality']);
     }
     if (isset($filters['shire_id']) && $filters['shire_id']) {
         $res->where('[s.shire_id] = %i', $filters['shire_id']);
     }
     $res->where('[s.deleted]', '=', '0');
     $res->groupBy('s.id');
     $res->orderBy($orderBy, $sort);
     $res->offset($offset);
     $res->limit($limit);
     $items = $res->fetchAll();
     foreach ($items as $k => $n) {
         $this->getFlags($n);
         $res = dibi::select('[c].*')->from('[categories] as [c]')->leftJoin('[subject_x_category] as [sc]')->on('sc.category_id', '=', 'c.id')->where('sc.subject_id', '=', $n->id);
         $items[$k]['categories'] = $res->fetchAll();
         $items[$k]['photos'] = Galleries::fetchPhotosByModule($n->id, 'subject');
     }
     return $items;
 }