1 year ago

Model::paginate() and then ->append('attribute')

Posted 1 year ago by neeonline

Hello all,

I'm using Laravel's Database Pagination (, everything work fine...

I came to a dead-[I can't find it in Google]-end. So, let's get a User model with pagination:

$users = User::paginate(15);

If needed I can add query params to the links object:

$users = User::paginate(15)->appends(['queryParam' => 'paramValue']);

But I can't append an attribute to the result set, everything that I tried failed =(

$users = User::paginate(15)->append('userAttribute');

I know it's possible to add the attribute to the protected $appends array, but this append is based on security level. So not all users should see this value.

Any help is appreciate.


Please sign in or create an account to participate in this conversation.