I'm not sure, but if you copy-pasted the code try fixing your syntax error first. $properties = $this->builder->orderBy('price')->paginate(15);
Jul 5, 2016
4
Level 30
Help with pagination
Here is my function that checks to see which property type was chosen, then does a couple where queries. The tables (Residential, Apartment, Rental) all have identical fields just different data:
public function searchProperties(Request $request)
{
$type = $request->input('propertyType');
if($type == "residential")
{
$this->builder = Residential::where('testField', '!=',null);
}
elseif($type == "apartment")
{
$this->builder= Apartment::where('testField', '!=',null);
}
elseif($type == "rental")
{
$this->builder = Rental::where('testField', '!=',null);
}
if($request->input('streetName'))
{
$this->builder->where('streetName', 'LIKE', '%'.$request->input('streetName').'%');
}
$properties = $this->builder->orderBy('price)->paginate(15);
return view('search.results',compact('properties'));
}
The result of this works fine, but and the pagination does show up correctly with the follow code in my view: {{ $properties->render() }}
Yet when I click on any of the pagination links I get this error: FatalErrorException in SearchController.php line 293: Call to undefined method Illuminate\Database\Schema\Builder::orderBy()
Any help would be appreciated.
Please or to participate in this conversation.