1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- namespace App\ModelFilters;
- use EloquentFilter\ModelFilter;
- class CustomFieldFilter extends ModelFilter
- {
- /**
- * Related Models that have ModelFilters as well as the method on the ModelFilter
- * As [relationMethod => [input_key1, input_key2]].
- *
- * @var array
- */
- public $relations = [];
- public function group($group)
- {
- return $this->where("group", $group);
- }
- public function key($key){
- return $this->where("key", "like", "%$key%");
- }
- public function batch($batch)
- {
- $in = [];
- foreach ($batch as $item) {
- $in[] = sprintf("'%s'", $item);
- }
- return $this->whereRaw(sprintf("concat(`group`, '.', `key`) in (%s)", implode(',', $in)));
- }
- }
|