laratrust icon indicating copy to clipboard operation
laratrust copied to clipboard

Add once() Helper Function To Role and Permission Checking.

Open onairmarc opened this issue 2 months ago • 8 comments

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

onairmarc avatar Apr 17 '24 16:04 onairmarc