rashan88's avatar

FatalErrorException ERROR Call to a member function links() on string

i am trying to laravel pagination but when i am clicking on 2nd link above error is comming

here my controller `` $searchResult = Property::where('purpose', $request['purpose']) ->whereHas('city', function ($qry) use ($cityName) { $qry->where('name', 'like', $cityName); }) ->whereHas('catagory', function ($qry) use ($catagory) { $qry->where('type', $catagory); })->paginate(1);

            $catagories = Catagory::all();

            return view('view-search.view-search')
                ->with('data',$searchResult)
                ->with('categories', $catagories)
                ->with('purpose', $request['purpose'])
                ->with('route', $routename)
                ->with('property_type',$request['selected-property-type-buy'])
                ->with('pagination', $searchResult);

here my blade code

{{$data->links()}}

``

0 likes
1 reply
tykus's avatar

...when i am clicking on 2nd link...

What 2nd link? Do the pagination links get rendered for the first page?

It would seem that $data is not what you think, i.e. a string rather than an instance of Paginator; perhaps you are overwriting $data elsewhere? Maybe choose a more meaningful variable name for your Property results, e.g. $properties - you mught be less likely to accidentally overwrite this variable name.

Please or to participate in this conversation.