Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Randy_Johnson's avatar

Vue3 Pagination

Why is it that I can not use the bottom syntax.

    return Inertia::render('Users', [
        'users' => \App\Models\User::paginate(10)->through(fn($user) => [
            'id' => $user->id,
            'name' => $user->name,
        ]),
    ]);
    return Inertia::render('Users', [
        'users' => \App\Models\User::select('id', 'name')->paginate(10)->all(),
    ]);
0 likes
3 replies
MohamedTammam's avatar
Level 51

It's like this

'users' => \App\Models\User::select('id', 'name')->paginate(10)

Why you were using all with pagination?

2 likes
Randy_Johnson's avatar

@MohamedTammam That's crazy! I cannot understand why they would show the other way instead of this, or even just to mention this way.

Please or to participate in this conversation.