Leong
Leong

Reputation: 139

laravel database notificaion paginate not working

Hi I try to implement pagination on laravel database notification but it seems not working at all.

Code:

$notifications = $user->notifications->paginate(3) ;

Error:

BadMethodCallException
Method Illuminate\Notifications\DatabaseNotificationCollection::paginate does not exist.

According to here https://github.com/laravel/framework/issues/15315 and here https://laracasts.com/discuss/channels/eloquent/how-to-paginate-laravel-53-database-notifications $user->notifications->paginate(3); this is the correct way to paginate.

Does laravel version update cause this not working ??

public function newCollection(array $models = [])
{
    return new DatabaseNotificationCollection($models);
}

Its returning a new collection in side the DatabaseNotification class. Any turnaround method? Or my code is wrong?

Thanks for reading any help will be highly appreciated (bow).

Upvotes: 0

Views: 726

Answers (1)

Mihail Simbirsky
Mihail Simbirsky

Reputation: 80

Try adding

$user->notifications()->paginate(3);

instead of

$user->notifications

Upvotes: 3

Related Questions