public function search($input, $getResults = true) { $query = AgentHasUser::query(); $columns = Schema::getColumnListing('agentHasUsers'); $attributes = array(); foreach ($columns as $attribute) { if (isset($input[$attribute]) and !empty($input[$attribute])) { $query->where($attribute, $input[$attribute]); $attributes[$attribute] = $input[$attribute]; } else { $attributes[$attribute] = null; } } if ($getResults) { return [$query->get(), $attributes]; } else { return $query; } }
/** * @return \Illuminate\Database\Eloquent\Builder */ protected function getQuery() { return AgentHasUser::query(); }