public function search($input, $getResults = true) { $query = Discuss::query(); $columns = Schema::getColumnListing('discusses'); $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 Discuss::query(); }