Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Users And Roles
salimi-my/admin-dashboard-template
cursor
authorization
roles
policies
form-requests
api-resources
inertia
pest

Conventions for roles, authorization and user management in the backend

Install
php artisan boost:add-skill salimi-my/admin-dashboard-template

Save this content to: .cursor/rules/users-and-roles.mdc

# Users, roles and authorization

- Roles are the `App\Enums\UserRole` backed enum stored in a plain string column. Add roles as enum cases (least privileged first, it is the default) and never as a database enum column.
- Authorize through `App\Policies\UserPolicy` or Form Request `authorize()`. Do not compare roles inline in controllers.
- Return API Resources (`UserResource`) to Inertia pages, not raw models.
- Flash user feedback with `Inertia::flash('toast', ['type' => 'success', 'message' => __('...')])`.
- Index endpoints validate `search`, filter arrays, `sort`, `direction` and `per_page` in a Form Request and cap `per_page`.
- Cover controller behavior and authorization failures with Pest feature tests that use the model factories.

Users, roles and authorization

  • Roles are the App\Enums\UserRole backed enum stored in a plain string column. Add roles as enum cases (least privileged first, it is the default) and never as a database enum column.
  • Authorize through App\Policies\UserPolicy or Form Request authorize(). Do not compare roles inline in controllers.
  • Return API Resources (UserResource) to Inertia pages, not raw models.
  • Flash user feedback with Inertia::flash('toast', ['type' => 'success', 'message' => __('...')]).
  • Index endpoints validate search, filter arrays, sort, direction and per_page in a Form Request and cap per_page.
  • Cover controller behavior and authorization failures with Pest feature tests that use the model factories.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
skyraptor/chatter
edlugz/sasapay
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource