Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Error Call to a member function paginate() on string

I’m currently working on a search data filter and when I click it it’s an error Call to a member function paginate() on string

Controller

public function index(Request $request){
        if($request->has('search')){
            $data = rekap::where('costumer','LIKE','%' .$request->search. '%'->paginate(5));
        }else{
            $data = rekap::paginate(5);
        }
        
        return view('rekap', compact('data'));
    }

View

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

      <form action="/rekap" method="GET">
      <div class="input-group mb-3">
        <input type="text" class="form-control" placeholder="Cari..." name="search">
        <button class="btn btn-info" type="submit">Search</button>
      </div>
       </form>

{{ $data->links() }}


   

>Solution :

change your return like this

 if($request->has('search')){
        $data = rekap::where('costumer','LIKE','%' .$request->search. '%')->paginate(5);
    }else{
        $data = rekap::paginate(5);
    }
return view('blade name here')->with([
        'data' => $data,
    ]);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading