Open ruchengtang opened 5 years ago
$this->ofInput('name', $searchData, 'and', true) ->ofInput('cellphone', $searchData, 'and', true) ->findAll();
Custom base model method:
/** * Search from request input. * * @param Builder $query * @param string $field * @param string|array $value * @param string $boolean * @param bool $like * * @return Builder */ public function scopeOfInput($query, $field, $value, $boolean = 'and', $like = false) { if (is_array($value) && !isset($value[$field])) { return $query; } return $this->_where($query, $field, $value[$field], $boolean, $like); }
Code Climate has analyzed commit 60a37b87 and detected 0 issues on this pull request.
View more on Code Climate.
Custom base model method: