| Conditions | 6 |
| Paths | 11 |
| Total Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 47 | protected function applySearch($query = '') |
||
| 48 | { |
||
| 49 | /** @var Model $model */ |
||
| 50 | $model = $this->model(); |
||
| 51 | |||
| 52 | if ($this->search instanceof \Closure) { |
||
| 53 | return call_user_func($this->search, $model, $query); |
||
| 54 | } |
||
| 55 | |||
| 56 | if (is_string($this->search)) { |
||
| 57 | $this->search = [$this->search]; |
||
| 58 | } |
||
| 59 | |||
| 60 | if (is_array($this->search)) { |
||
| 61 | $connectionType = $model->eloquent()->getConnection()->getDriverName(); |
||
| 62 | $likeOperator = $connectionType == 'pgsql' ? 'ilike' : 'like'; |
||
| 63 | |||
| 64 | foreach ($this->search as $column) { |
||
| 65 | $model->orWhere($column, $likeOperator, '%'.$query.'%'); |
||
| 66 | } |
||
| 67 | } |
||
| 68 | } |
||
| 69 | } |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: