The "with" filter for the QueryFilters
This commit is contained in:
parent
11aec2d63c
commit
eaddb9c8b6
1 changed files with 14 additions and 0 deletions
|
|
@ -52,6 +52,13 @@ abstract class QueryFilters
|
|||
*/
|
||||
protected $builder;
|
||||
|
||||
/**
|
||||
* The "with" filter property column.
|
||||
*
|
||||
* var string
|
||||
*/
|
||||
protected $with_property = 'id';
|
||||
|
||||
/**
|
||||
* Create a new QueryFilters instance.
|
||||
*
|
||||
|
|
@ -218,4 +225,11 @@ abstract class QueryFilters
|
|||
|
||||
return $this->builder;
|
||||
}
|
||||
|
||||
public function with(string $value): Builder
|
||||
{
|
||||
return $this->builder
|
||||
->orWhere($this->with_property, $value)
|
||||
->orderByRaw("{$this->with_property} = ? DESC", [$value]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue