filter search fix
This commit is contained in:
parent
72f528e75d
commit
a549c0ed75
@ -55,6 +55,11 @@ try {
|
|||||||
'class' => \Itguild\Tables\Filter\InputTextFilter::class
|
'class' => \Itguild\Tables\Filter\InputTextFilter::class
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
'role' => [
|
||||||
|
'filter' => [
|
||||||
|
'class' => \Itguild\Tables\Filter\InputTextFilter::class
|
||||||
|
],
|
||||||
|
],
|
||||||
'created_at' => [
|
'created_at' => [
|
||||||
'format' => 'date:d-m-Y',
|
'format' => 'date:d-m-Y',
|
||||||
'filter' => [
|
'filter' => [
|
||||||
|
@ -4,6 +4,7 @@ namespace Itguild\EloquentTable;
|
|||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Facades\App;
|
||||||
use itguild\forms\debug\Debug;
|
use itguild\forms\debug\Debug;
|
||||||
|
|
||||||
class EloquentDataProvider
|
class EloquentDataProvider
|
||||||
@ -61,8 +62,13 @@ class EloquentDataProvider
|
|||||||
if ($this->meta['searchParams']){
|
if ($this->meta['searchParams']){
|
||||||
foreach ($this->meta['searchParams'] as $name => $param){
|
foreach ($this->meta['searchParams'] as $name => $param){
|
||||||
if (array_key_exists($name, $this->meta['columns']) && !empty($param)){
|
if (array_key_exists($name, $this->meta['columns']) && !empty($param)){
|
||||||
|
if (is_numeric($param)){
|
||||||
$this->queryBuilder->where($name, $this->meta['searchParams'][$name]);
|
$this->queryBuilder->where($name, $this->meta['searchParams'][$name]);
|
||||||
}
|
}
|
||||||
|
elseif (is_string($param)){
|
||||||
|
$this->queryBuilder->where($name,'like', '%' . $param. '%');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($this->currentPage > 1) {
|
if ($this->currentPage > 1) {
|
||||||
|
@ -21,7 +21,8 @@ class User extends Model {
|
|||||||
'username' => 'Логин',
|
'username' => 'Логин',
|
||||||
'email' => 'Email',
|
'email' => 'Email',
|
||||||
'created_at' => 'Создан',
|
'created_at' => 'Создан',
|
||||||
'updated_at' => 'Обновлен'
|
'updated_at' => 'Обновлен',
|
||||||
|
'role' => 'Роль'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user