Laravel Method paginate does not exist

前端 未结 5 1646
情深已故
情深已故 2021-02-01 06:55

I am trying to paginate Model result, but I am getting \"Method paginate does not exist.\". Here is my code:

$user_dispatches = Dispatch::all()->where(\'user_         


        
5条回答
  •  别那么骄傲
    2021-02-01 07:11

    You need to remove all():

    Dispatch::where('user_id', Auth::id())->paginate(10);
    

    When you're using all() you get all the rows from the table and get a collection. Then you're using collection method where() (and not Query Builder method where()) and then you're trying to use paginate() method on the collection and it doesn't exist.

提交回复
热议问题