codemode's avatar

Pagination error

I'm trying to paginate my view, but i get this error - Call to undefined method Illuminate\Database\Query\Builder::links()

Controller function -

public function index()
    {
        
        $imc_obj = Imc::where('user_id', Auth::id())->paginate(5);
      
        return view('imc.index', compact('imc_obj'));
        
        
    }

View file -

@foreach ($imc_obj as $imcs)
                      <tr>
                        <td>{{ $imcs->name }}</td>
                        <td>{{ date('F d, Y', strtotime($imcs->created_at)) }}</td>
                        
                      </tr>
                        @endforeach
                    </tbody>
                  </table>
                  {{ $imcs->links() }}
0 likes
1 reply
jlrdw's avatar
jlrdw
Best Answer
Level 75

Change

{{ $imcs->links() }}

to

{{ $imc_obj->links() }}
1 like

Please or to participate in this conversation.