pagination - Laravel - Paginating Eloquent Retrieved results -
this have in controller
$projects=project::where_sup_id($user_id)->get(); $total=count($projects); $per_page=3; $projects = paginator::make($projects, $total, $per_page); homecoming view::make('project.index')->with('projects',$projects);
and in view
@foreach ($projects->results $project) {{$project->title}} @endforeach {{$projects->links();}}
but when view in browser displaying rows in pages...the links displaying perfectly! u think problem? please help! give thanks u in advance!
you counting rows, not using limit
@ all, laravel fluent query builder has skip()
, take()
method that.
btw, don't need manually paginate it. laravel pagination automatically paginate()
method.
do way:
$projects = project::where_sup_id($user_id)->paginate(3); // 3 means records per page homecoming view::make('project.index')->with('projects', $projects);
you doing view
work correctly.
pagination laravel eloquent
No comments:
Post a Comment