Beispiel #1
0
 /**
  * Возвращает коллекцию в виде пагинации
  *
  * @param int $page
  * @param int $limit
  */
 public function pagination($page, $limit = 10)
 {
     /**
      * @var \Illuminate\Support\Collection $data
      */
     $countTotal = $this->_query->count();
     $this->_query->skip($limit * $page - $limit);
     $this->_query->limit($limit);
     $data = collect();
     foreach ($this->_query->get() as $key => $instance) {
         $_listRow = [];
         foreach ($this->columns->getColumns() as $column) {
             $_listRow[$column->getKey()] = $column->getValues($instance);
         }
         $buttons = $this->filterAction($instance);
         if (count($buttons)) {
             $_listRow = array_merge($_listRow, [GridColumn::ACTION_NAME => implode('', $buttons)]);
         }
         $data->offsetSet($key, $_listRow);
     }
     return new \Illuminate\Pagination\LengthAwarePaginator($data, $countTotal, $limit, $page, ['path' => \Illuminate\Pagination\Paginator::resolveCurrentPath(), 'pageName' => 'page']);
 }
 /**
  * Used primarily by testing to reset the count used to define the unique column alias names.
  */
 public static function resetCount()
 {
     static::$count = 0;
 }
Beispiel #3
0
 /**
  * Builds the tree recursive
  */
 public function buildTree()
 {
     if (!$this->isValid()) {
         throw new \RuntimeException('The tree is not set up properly.');
     } else {
         $iterator = new \DirectoryIterator($this->_filepath);
         foreach ($iterator as $file_info) {
             if (!$file_info->isDot() && !$this->_search->isPathIgnored($file_info->getPathname())) {
                 // Subtree?
                 if ($file_info->isDir()) {
                     // Recursion
                     $sub_tree = new static($this->_search, $file_info->getPathname());
                     $sub_tree->setLeafObjectClass($this->_leaf_object_class);
                     $sub_tree->buildTree();
                     if ($sub_tree->isValid()) {
                         if (!$this->getOptions()->get(Opt::EMPTY_FOLDERS_HIDDEN) || $sub_tree->count() > 0) {
                             $this->_entries[] = $sub_tree;
                         }
                     }
                 } elseif ($file_info->isFile()) {
                     $leaf = $this->getLeafObject($file_info->getPathname());
                     if ($leaf->isValid()) {
                         $this->_entries[] = $leaf;
                     }
                 }
             }
         }
         // Error on empty directories
         if (!$this->getOptions()->get(Opt::EMPTY_FOLDERS_HIDDEN) && !$this->hasFiles()) {
             $leaf = $this->getLeafObject($this->_filepath);
             $leaf->setError("Directory has no files matching the filter.");
             $this->_entries[] = $leaf;
         }
         // Sort by folder and file and by name
         usort($this->_entries, function (Entry $a, Entry $b) {
             if ($a instanceof Tree && $b instanceof Leaf) {
                 return -1;
             } elseif ($a instanceof Leaf && $b instanceof Tree) {
                 return 1;
             } else {
                 return strnatcasecmp($a->getFilename(), $b->getFilename());
             }
         });
     }
 }
Beispiel #4
0
 public static function setCount($count)
 {
     static::$count = $count;
     return static::$count++;
 }
Beispiel #5
0
 /**
  * Get the number of messages in the default bag.
  *
  * @return int
  */
 public function count()
 {
     return $this->default->count();
 }