search params

This commit is contained in:
2024-12-23 17:24:30 +03:00
parent 13b54a563d
commit 72f528e75d
4 changed files with 13 additions and 2046 deletions

View File

@ -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 {