- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
public function filters($collection)
{
$className = $collection->modelName();
$filters = null;
$config = $this->getConfig($className)->admin_panel;
if (!empty($config['filters'])) {
$filters = $config['filters'];
}
if (!$filters) {
return $collection->raw();
}
foreach ($filters as $field => $value) {
if (strpos($value, '||')) {
$or = explode('||', $value);
$where = "";
foreach ($or as $value) {
if (strpos($value, '::') !== false) {
$value = call_user_func(trim($value));
}
$where .= $field . '="' . $value . '" OR ';
}
$collection->where('(' . substr($where, 0, -4) . ')');
} else {
if (strpos($value, '::') !== false) {
$value = call_user_func(trim($value));
}
$collection->where($field, trim($value));
}
}
return $collectio->raw();
}
Комментарии (0) RSS
Добавить комментарий