search params
This commit is contained in:
@ -49,6 +49,7 @@ class EloquentDataProvider
|
||||
$this->meta['params'] = $options['params'] ?? [];
|
||||
$this->meta['actions'] = $options['actions'] ?? [];
|
||||
$this->meta['searchPrefix'] = $options['searchPrefix'] ?? '/search';
|
||||
$this->meta['searchParams'] = $options['searchParams'] ?? [];
|
||||
$this->meta['showFiltersRow'] = $options['showFiltersRow'] ?? true;
|
||||
$this->filters = $options['filters'] ?? [];
|
||||
$this->createQuery();
|
||||
@ -57,6 +58,13 @@ class EloquentDataProvider
|
||||
|
||||
public function createQuery(): void
|
||||
{
|
||||
if ($this->meta['searchParams']){
|
||||
foreach ($this->meta['searchParams'] as $name => $param){
|
||||
if (array_key_exists($name, $this->meta['columns']) && !empty($param)){
|
||||
$this->queryBuilder->where($name, $this->meta['searchParams'][$name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($this->currentPage > 1) {
|
||||
$this->queryBuilder->skip(($this->currentPage - 1) * $this->perPage)->take($this->perPage);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user