Weave Code
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

Laratrust Laravel Package

santigarcor/laratrust

Laratrust adds role and permission management to Laravel with support for multiple user models, teams, guards, caching, events, middleware, gates/policies, and an optional admin panel for managing roles and permissions.

View on GitHub
Deep Wiki
Context7

Troubleshooting


If you make changes directly to the Laratrust tables and when you run your code the changes are not reflected, please clear your application cache using::

php artisan cache:clear

Remember that Laratrust uses cache in the roles and permissions checks.


If you want to use the Authorizable trait you have to do:

use Authorizable {
    Authorizable::can insteadof LaratrustUserTrait;
    LaratrustUserTrait::can as laratrustCan;
}

And then replace all the uses of can with hasPermission or isAbleTo.

::: tip NOTE If you use the Laratrust::can facade method you don't have to change this method because it calls the hasPermission method. :::


If you encounter an error when doing the migration that looks like::

SQLSTATE[HY000]: General error: 1005 Can't create table 'laravelbootstrapstarter.#sql-42c_f8' (errno: 150)
    (SQL: alter table `role_user` add constraint role_user_user_id_foreign foreign key (`user_id`)
    references `users` (`id`)) (Bindings: array ())

Then it is likely that the id column in your user table does not match the user_id column in role_user. Make sure both are INT(10).


When trying to use the LaratrustUserTrait methods, you encounter the error which looks like::

Class name must be a valid object or a string

Then probably you do not have published Laratrust assets or something went wrong when you did it. First of all check that you have the laratrust.php file in your app/config directory. If you don't, then try php artisan vendor:publish and, if it does not appear, manually copy the /vendor/santigarcor/laratrust/src/config/config.php file in your config directory and rename it laratrust.php.


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.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle