Get all media in the collection.

@param \Spatie\MediaLibrary\HasMedia\HasMedia $model
@param string $collectionName
@param array|callable $filter

@return \Illuminate\Support\Collection
190081
public function getCollection(HasMedia $model, string $collectionName, $filter = []): Collection
    {
        return $this->applyFilterToMediaCollection($model->loadMedia($collectionName), $filter);
    }
867460
public function addFilter(FilterInterface $filter)
    {
        if ($this->containsFilter($filter)) {
            throw new CollectionException(sprintf(
                'Collection already contains key "%s".', $filter->getName()
            ));
        }

        $this->add($filter);

        return $this;
    }
1196607
private function buildQuery(Model $model = null)
    {
        $query = $this->model->collections();

        $query = $query->whereCollectionName($this->collectionName);

        if ($model) {
            $query = $query->where('item_id', $model->id)
                           ->where('item_type', get_class($model));
        }

        if (!$model && $this->itemType) {
            $query = $query->where('item_type', '=', $this->itemType);
        }

        return $query;
    }
732805
public function provideFilter($filter = null)
    {
        if ($filter === null) {
            $filter = config('eloquentfilter.namespace', 'App\\ModelFilters\\').class_basename($this).'Filter';
        }

        return $filter;
    }
1166091
public function getServices($filter = null)
	{
		$services = array();

		// Create the request
		$request = new client\Request('/api/mpegts/service/grid');

		if ($filter)
			$request->setFilter($filter);

		// Get the response
		$response = $this->_client->getResponse($request);
		$rawContent = $response->getContent();

		$content = json_decode($rawContent);

		foreach ($content->entries as $entry)
			$services[] = model\Service::fromRawEntry($entry);

		return $services;
	}
748081
protected function listFolderItems($folder, $filter, $sortBy)
    {
        $filter = $filter !== self::FILTER_EVERYTHING ? $filter : null;

        return MediaLibrary::instance()->listFolderContents($folder, $sortBy, $filter);
    }
270510
public function collection($items, $transformer, $model_name = '', $meta = [])
    {
        $resource = new Collection($items, $transformer, $model_name);

        $resource->setMeta($meta);
        if ($items instanceof LengthAwarePaginator) {
            $resource->setPaginator(new IlluminatePaginatorAdapter($items));
        }

        return $this->manager->createData($resource)->toArray();
    }
1218663
public function findOneAndDelete(array $filter, array $options = [])
    {
        $options['typeMap'] = [
            'root' => $this->documentManager->getProxyClass($this->documentClass),
            'document' => 'array',
        ];

        $document = $this->getCollection()->findOneAndDelete($filter, $options);
        if ($document instanceof DocumentManagerAwareInterface) {
            $document->setManager($this->documentManager);
        }

        return $document;
    }
802525
public function update($model, $filter = null, array $options = [])
    {
        if (null === $filter) {
            $filter = ['_id' => get_object_id($model)];
        }

        $useOptimisticLock = false;
        if (isset($options['optimistic_lock']) && $options['optimistic_lock']) {
            $useOptimisticLock = true;

            if (false == $version = get_value($model, 'version', false)) {
                throw new \LogicException('The optimistic lock has been requested but version field is not set on the model');
            }

            $filter = array_merge($filter, ['version' => $version]);
        }
        unset($options['optimistic_lock']);

        $originalValues = $this->changesCollector->getOriginalValues($model);
        $values = $this->convertValues->convertToMongoValues(get_values($model, true), $originalValues ?: []);

        $update = $this->changesCollector->changes($values, $originalValues);
        if (empty($update)) {
            return;
        }

        if ($useOptimisticLock) {
            if (false == isset($update['$inc'])) {
                $update['$inc'] = [];
            }

            $update['$inc']['version'] = 1;
        }

        // mongodb's update cannot do a change of existing element and push a new one to a collection.
        $pushUpdate = [];
        $result = null;
        if (array_key_exists('$push', $update)) {
            $pushUpdate['$push'] = $update['$push'];
            unset($update['$push']);

            $this->collection->updateOne($filter, $pushUpdate, $options);

            if ($update) {
                $result = $this->collection->updateOne($filter, $update, $options);
            }
        } else {
            $result = $this->collection->updateOne($filter, $update, $options);
        }

        if ($useOptimisticLock && 0 === $result->getModifiedCount()) {
            throw OptimisticLockException::lockFailed();
        }

        if ($useOptimisticLock) {
            set_value($model, 'version', $version + 1);
        }

        if ($result && $result->getUpsertedCount()) {
            set_object_id($model, new ObjectID((string) $result->getUpsertedId()));
        }

        $this->changesCollector->register($model, $values ?: []);

        return $result;
    }
1000775
public function collectionAction($collection, Request $request = null)
    {
        $action = $this->container->get(CollectionPostArchiveAction::class);

        return $action($this->resolveRequest($request), $collection);
    }
1201934
public function channels(array $filter = array()) {
        $this->setTokenValue($this->getEntityIdName(), $this->getId());

        $collection_name = '\\Kazoo\\Api\\Collection\\Channels';
        return new $collection_name($this, array($filter));
    }
1196180
public static function where($filter, $value = null)
    {
        if (is_scalar($filter)) {
            /** @var \ManaPHP\ModelInterface $model */
            $model = Di::getDefault()->getShared(static::class);
            return static::query(null, $model)->whereEq($model->getPrimaryKey(), $filter);
        } else {
            return static::query()->where($filter, $value);
        }
    }
236121
public function getAll($collection, array $options = [])
    {
        /** @var AbstractHttpRequest $request */
        $request          = $this->getRequest();
        $request->options = $options;
        $request->path    = $this->client->fullDatabasePath . static::API_PATH;
        $request->path .= '?collection=' . $collection;
        $request->method = static::METHOD_GET;

        return $this->getReturnObject($request);
    }
1090442
public function parseFilter($filter, $model)
    {
        $this->guardProviderNames(null, $model);

        $applied = [
            'operation' => $filter['operation'],
        ];

        if (isset($filter['local'])) {
            $applied['property'] = $filter['local'];
        }

        if (isset($filter['remote'])) {
            $applied['value'] = $model->getProperty($filter['remote']);
        }

        if (isset($filter['remote_value'])) {
            $applied['value'] = $filter['remote_value'];
        }

        if (isset($filter['value'])) {
            $applied['value'] = $filter['value'];
        }

        if (isset($filter['children'])) {
            foreach ($filter['children'] as $child) {
                $applied['children'][] = $this->parseFilter($child, $model);
            }
        }

        return $applied;
    }
620668
public function getMethods($filter = null)
    {
        if ($this->methods === null) {
            // lazy load class methods list
            $this->methods = array();
            foreach ($this->node->stmts as $stmt) {
                if ($stmt instanceof Node\Stmt\ClassMethod) {
                    $stmt->setAttribute('fileName', $this->getFileName());
                    $this->methods[$stmt->name] = new MethodModel($this, $stmt);
                }
            }
        }

        if (isset($filter)) {
            // @TODO must implement the filter feature
            $methods =& $this->methods;
        } else {
            $methods =& $this->methods;
        }

        return array_values($methods);
    }
420976
public static function findLast(Filter ...$filters)
    {
        $results = static::find(...$filters);
        $modelClass = get_called_class();
        /** @var Model $model */
        $model = new $modelClass();
        $results->addSort($model->getUniqueIdentifierColumnName(), false);

        if (sizeof($results) == 0) {
            throw new RecordNotFoundException(get_called_class(), 0);
        }

        return $results[0];
    }
1046033
public function getMedia(string $collectionName = 'default', $filters = []): Collection
    {
        return app(MediaRepository::class)->getCollection($this, $collectionName, $filters);
    }