public static function _getLists($options = array()) { $orderBy = !empty($options['order_by']) ? $options['order_by'] : self::DEFAULT_ORDER_BY; $orderByType = !empty($options['order_by_type']) ? $options['order_by_type'] : self::DEFAULT_ORDER_BY_TYPE; $listsQuery = ViralList::approved()->with('category'); //Tag filter if (!empty($options['ofTag'])) { $listsQuery->withAllTags($options['ofTag']); } $listsQuery->orderBy($orderBy, $orderByType); $limit = isset($options['limit']) ? $options['limit'] : self::getPerPageLimit(); if (!empty($options['exclude'])) { $listsQuery->exclude($options['exclude']); } if (!empty($options['categoryId'])) { $listsQuery->ofCategory($options['categoryId']); } if (!empty($options['search'])) { $listsQuery->search($options['search']); } //dd($listsQuery->toSql()); $lists = $listsQuery->simplePaginate($limit); foreach ($lists as $key => $list) { $lists[$key] = $list; } self::touchUpLists($lists); //dd($lists->toArray()); return $lists; }