Skip to content

Support for magic calls

Choose a tag to compare

@ajimoti ajimoti released this 15 Jan 01:17
· 38 commits to main since this release
9adc19d

For example:

After a model has been assigned a role, we shouldn't have to always use the ->hasRole() method to check if the user has a specific role. Or the holds() method to check if the model holds a permission. Developers should be able to prepend is with the role key and make a call on the model like so:

// $model->is{role_key}()
$model->isSuperAdmin(); // returns bool

// Or on a many-to-many relationship
$user->of($model)->isSuperAdmin();

Similarly, perpend can with the permission to check if the model has permission:

// $model->can{permission_key}()
$model->canDeleteTransactions(); // returns bool

// Or on a many-to-many relationship
$user->of($model)->canDeleteTransactions();

What's Changed

  • Include support for magic calls. by @ajimoti in #1

New Contributors

Full Changelog: 1.0.0...1.1.0