Skip to content

WhereIdIn filter doesn't work #68

@mspiderv

Description

@mspiderv

Version: v1.0.0-beta.1

Im getting this error "Expecting filter value to be an array, or a string when a string delimiter is set.".

URL Im hitting: http://localhost:8000/api/jsonapi/product-categories?filter[id]=3

My filters method in Schema class:

public function filters(): array
    {
        return [
            WhereIdIn::make($this),
        ];
    }

I think the problem is here: /vendor/laravel-json-api/eloquent/src/Filters/Concerns/HasDelimiter.php on line 53:

protected function toArray($value): array
    {
        if ($this->delimiter && \is_string($value)) {
            return \explode($this->delimiter, $value);
        }

        if (\is_array($value)) {
            return $value;
        }

        throw new \LogicException(
            'Expecting filter value to be an array, or a string when a string delimiter is set.'
        );
    }

This method throws that error, because the $value is simply a string.

I think this is a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions