add support for filter expression
This commit is contained in:
parent
07e80965a4
commit
5f7c0d2da5
|
|
@ -50,6 +50,13 @@ interface AdapterInterface
|
|||
*/
|
||||
public function filterByRelationship($query, Relationship $relationship, Closure $scope): void;
|
||||
|
||||
/**
|
||||
* Manipulate the query to only include resources appropriate to given filter expression.
|
||||
*
|
||||
* @param string $expression The filter expression
|
||||
*/
|
||||
public function filterByExpression($query, string $expression): void;
|
||||
|
||||
/**
|
||||
* Manipulate the query to sort by the given attribute in the given direction.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -61,6 +61,10 @@ class EloquentAdapter implements AdapterInterface
|
|||
$query->whereHas($this->getRelationshipProperty($relationship), $scope);
|
||||
}
|
||||
|
||||
public function filterByExpression($query, string $expression): void
|
||||
{
|
||||
}
|
||||
|
||||
public function sortByAttribute($query, Attribute $attribute, string $direction): void
|
||||
{
|
||||
$query->orderBy($this->getAttributeProperty($attribute), $direction);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,10 @@ class NullAdapter implements AdapterInterface
|
|||
{
|
||||
}
|
||||
|
||||
public function filterByExpression($query, string $expression): void
|
||||
{
|
||||
}
|
||||
|
||||
public function sortByAttribute($query, Attribute $attribute, string $direction): void
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,6 +122,11 @@ final class ResourceType
|
|||
continue;
|
||||
}
|
||||
|
||||
if (is_int($name)) {
|
||||
$this->adapter->filterByExpression($query, $value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (
|
||||
isset($customFilters[$name])
|
||||
&& evaluate($customFilters[$name]->getVisible(), [$context])
|
||||
|
|
|
|||
Loading…
Reference in New Issue