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

PrinceMinky's avatar

Code Review

Hello everybody,

Just looking for guidance, suggestions and quality of life improvements for future developement.

I'm creating an admin control panel for Spatie Laravel Permissions, using Flux UI Pro.

With the below code I have crud functionality to add/edit/delete and view: users, roles and permissions. I've also implemented the logic so that if you can't "add permission" that it throws errors where needed etc.

Once I've finished I'll use this boilerplate for next applications such as blogs, site settings etc.

Known issues:

- When using paginate the query string from list.blade.php will also try and change the pages of roles and permissions. (temp fix: removed pagination from roles and permissions).

Fixed by, and thank you: @tykus

Todo:

  • User logs

index.blade.php

list.blade.php

roles.blade.php

permissions.blade.php

0 likes
3 replies
tykus's avatar
tykus
Best Answer
Level 104

Whenever you might have multiple paginators on the same view/page, you can specify a $pageName parameter to the paginate method, e.g.:

return User::query()
            ->tap(fn($query) => $this->sortBy ? $query->orderBy($this->sortBy, $this->sortDirection) : $query)
            ->with('roles')
            ->paginate(15, pageName: 'users-page');

https://livewire.laravel.com/docs/pagination#multiple-paginators

If you adopt this approach for the re-usable components, then the main content could use the default "page" parameter

tykus's avatar

@Minky no worries, please mark the thread solved if you're all set

Please or to participate in this conversation.