laratrust
laratrust copied to clipboard
Add once() Helper Function To Role and Permission Checking.
This PR adds the new once()
helper function to Laratrust along with the option to enable/disable it via the configuration file.
This is useful as it removes the need to override the hasRole()
and hasPermission()
methods on the user model and instead moves this logic into Laratrust itself.
The default is that the use of this function is disabled due to the once()
function not being added into Laravel Core until Laravel 11. The inline documentation comment with this configuration states that the application must be running Laravel 11 in order to use this function. The comment also states that if the application is running Laravel 10 or below, they need to run composer require spatie/once