public function apply($filter, Closure $callback = null)
    {
        // If the supplied filter is an array then we'll treat it as an array of filters that are
        // to be applied to the resource.
        if (is_array($filter))
        {
            return $this->applyFromArray($filter);
        }

        $filter = $this->factory->get('filter')->make($filter)->setResource($this);

        is_callable($callback) and call_user_func($callback, $filter);

        return $this->filters[$filter->getFilter()] = $filter;
    }