Returns a new collection containing only directories.

@return self
355471
public function dirs()
    {
        $filesList = array_filter($this->items, function($item) {
            return ($item['instance'] instanceof DirectoryInterface);
        });

        $filesList = array_map(function($item) {
            return $item['instance'];
        }, $filesList);

        return new Collection($filesList);
    }
1230330
public function create()
    {
        $instance = self::createCollection($this);
        $this->setId($instance->getId());
        return $instance;
    }
356878
public function directories($directory)
    {
        return collect($this->filesystem->directories($directory))
            ->map(function ($file) {
                return new File($file, $this);
            });
    }
971683
public function getHeaderCollection()
    {
        if ($this->_headerCollection === null) {
            $headerCollection = new HeaderCollection();
            $headerCollection->fromArray($this->defaultHeaders());
            $this->_headerCollection = $headerCollection;
        }
        return $this->_headerCollection;
    }
174122
public function rollback()
    {
        parent::rollback();
        foreach ($this->getOriginalAll() as $collection) {
            if ($collection instanceof Collection) {
                $collection->rollback();
            }
        }
        return $this;
    }
1132384
protected function prepareDefaultDirectory() : Directory {
        $path = $this->finder->setWorkingDirectory('/');

        return new Directory($this->factory, $this->finder, $path);
    }
1190687
protected function collection()
    {
        if (empty($this->collection)) {
            $this->collection = $this->factory()->assetCollection();
        }

        return $this->collection;
    }
684161
protected function _collection()
    {
        if (!isset($this->_collections[$this->_collection])) {
            $this->_collections[$this->_collection] = new $this->_collectionClass($this);
        }

        return $this->_collections[$this->_collection];
    }
102921
public function clean()
    {
        // Make sure the handle is close
        $this->close();

        $dir = dirname($this->getFile());
        if (is_dir($dir)) {
            $files = scandir($dir);
            foreach ($files as $file) {
                if ('.' != $file && '..' != $file) {
                    $file = $dir . DIRECTORY_SEPARATOR .  $file;
                    if (is_file($file)) {
                        unlink($file);
                    }
                }
            }
        }
        return $this;
    }
164432
public function shuffle(): Collection
    {
        // Get keys and shuffle
        $keys = array_keys($this->list);
        shuffle($keys);

        // Attribute shuffle keys to theirs values
        $newList = [];
        foreach ($keys as $key) {
            $newList[$key] = $this->list[$key];
        }

        // Update list
        $this->list = $newList;

        return $this;
    }
739123
public function allPermissions() : Collection
    {
        return $this->roles()->with('permissions')->get()->pluck('permissions')->flatten()->merge($this->permissions);
    }
40408
public function getDirectory()
    {
        $dir = new Directory($this->getDirname());

        $namespaces = explode('\\', $this->getNameSpace());
        array_pop($namespaces);
        $dir->setNamespace(join('\\', $namespaces));

        return $dir;
    }
410339
protected function getCollection()
    {
        $collection = [];

        $class = $this->getCollectionClassName();
        if ($class) {
            /** @var Collection $collection */
            $collection = new $class();
            $collection->setModel($this->class);
            $collection->setFormatter($this);
        }

        return $collection;
    }
1294309
public function tail() : Collection
    {
        $acc = [];
        foreach ($this->list as $index => $item) {
            if ($index > 0) {
                $acc[] = $item;
            }
        }

        return self::from(...$acc);
    }
856138
protected function checkDirectory()
    {
        $directoryPath = $this
            ->directory
            ->getDirectoryPath();

        if (!is_dir($directoryPath)) {

            mkdir($directoryPath);
        }

        return $this;
    }
1285985
public static function instances(): BaseCollection
    {
        $instances = new BaseCollection;

        foreach (static::make()->all() as $key => $value) {
            if ($instance = self::instance($key)) {
                $instances->put($key, $instance);
            }
        }

        return $instances;
    }
451
public function unique() : Collection
    {
        $acc = [];
        foreach ($this->list as $item) {
            if (!in_array($item, $acc)) {
                $acc[] = $item;
            }
        }

        return self::from(...$acc);
    }