public function applyCriteria($criteria)
    {
        $query = $this->getQuery();

        if($criteria instanceof Criteria){
            $criteria->apply($query);

            return $this;
        }

        if($criteria instanceof Closure){
            $criteria($query);

            return $this;
        }

        throw new RepositoryException("Must be an instance of " . Criteria::class . " or \\Closure");
    }