Example #1
0
 /**
  * Paginate the given criteria
  * @param Builder $criteria
  * @param unknown $columns
  * @return \App\Core\PaginatorCore
  */
 public function paginate($criteria, $columns = ['*'])
 {
     if ($criteria instanceof Illuminate\Database\Eloquent\Builder) {
         $builder = $criteria->getQuery();
     } else {
         $builder = $criteria;
     }
     $pageName = 'page';
     $sortColumn = '';
     $sortOrder = '';
     $default = config('system.page_limit');
     $total = $builder->getCountForPagination();
     if (!is_null($this->request) && $this->request->has('page_limit')) {
         $perPage = $this->request->has('page_limit') ? $this->request->get('page_limit') : $default;
         $page = $this->request->has($pageName) ? $this->request->get($pageName) : null;
         $sortColumn = $this->request->has('sort') ? $this->request->get('sort') : '';
         $sortOrder = $this->request->has('order') ? $this->request->get('order') : '';
     } else {
         $perPage = $default;
     }
     $builder->forPage($page = Paginator::resolveCurrentPage($pageName), $perPage);
     if ($sortColumn) {
         $sortOrder = $sortOrder ? $sortOrder : $this->defaultSort;
         $criteria = $builder->orderBy($sortColumn, $sortOrder);
     }
     return new PaginatorCore($builder->get($columns), $total, $perPage, $page, ['path' => Paginator::resolveCurrentPath(), 'pageName' => $pageName, 'sortColumn' => $sortColumn, 'sortOrder' => $sortOrder]);
 }
 /**
  * Check if the locale is available.
  * 
  * @param string $locale
  */
 public function has($locale)
 {
     $this->initStorage();
     // Normalize locale
     $locale = str_replace('_', '-', $locale);
     if ($this->storage->has($locale)) {
         return true;
     }
     // Default locale is always allowed
     if (strcasecmp($locale, $this->getDefaultLocale()) === 0) {
         return true;
     }
     return false;
 }
Example #3
0
 /**
  * Clear data filter from session
  * @param string $key
  */
 protected function clear($key = '')
 {
     $data = $this->session->get('filters');
     if ($this->request->has('clear_filter')) {
         if (isset($data[$this->request->getPathInfo()])) {
             $this->session->set('filters.' . $this->request->getPathInfo(), '');
         }
     } elseif ($key) {
         if (isset($data[$this->request->getPathInfo()][$key])) {
             unset($data[$this->request->getPathInfo()][$key]);
             $this->session->set('filters', $data);
         }
     }
 }
Example #4
0
 /**
  * Check if the cart has a specific item
  * 
  * @param  string  $itemIdentifier The unique item identifier
  * @return boolean                 Yes or no?
  */
 public function has($itemIdentifier)
 {
     return $this->store->has($itemIdentifier);
 }