im using laravel v 5.5 i have the following Method
public function AllNotification ()
{
$data[ 'notifications' ] = Notification::ThisUser ()->latest ()->paginate ( 10 );
return view ('Notifications.allNotifications',$data);
}
and if i dd($data);
this is the result
when i show the view and print the content of {{dd($notifications)}}
this is what is shown and the $notifications->links()
is gone duo to that
im not sure what's happening as on all other methods its working fine
If you want to paginate a standard Laravel Collection in your views you can add this macro code to the AppServiceProvider
class within the boot()
function:
/**
* Paginate a standard Laravel Collection.
*
* @param int $perPage
* @param int $total
* @param int $page
* @param string $pageName
* @return array
*/
Collection::macro('paginate', function($perPage, $total = null, $page = null, $pageName = 'page') {
$page = $page ?: LengthAwarePaginator::resolveCurrentPage($pageName);
return new LengthAwarePaginator(
$this->forPage($page, $perPage),
$total ?: $this->count(),
$perPage,
$page,
[
'path' => LengthAwarePaginator::resolveCurrentPath(),
'pageName' => $pageName
]
);
});