+++ date = "2023-06-26" draft = false weight = 20 description = "A bunch of useful and handy methods." title = "Trait" bref= "Sphinx adds some useful and necessary methods through the trait. there is the list of available methods" toc = false +++
{{< rawhtml >}}
Determine if the entity has the given abilities.
$user->can('has-ability'); // ture
$user->can('hasnt-ability'); // false
Determine if the entity has any of the given abilities.
$user->canAny( ['has-ability','hasnt-ability'] ); // true
$user->canAny( ['hasnt-ability','hasnt-other-ability'] ); // false
Determine if the entity does not have the given abilities.
$user->cant('hasnt-ability'); // true
$user->cant('has-ability'); // false
Alias for cant method.
Determine the limitation of logged-in devices using one user account.
$user->getDeviceLimit(); // int number
Extract some necessary attributes of user to put in the tokens.
$user->extract(); // an array of user's attributes
Returns username column name of the user.
$user->username(); // email column for example
Extract attributes of user's role.
$user->extractRole(); // an array of user's role attributes
Extract attributes of owned permissions of user.
$user->extractPermissions(); // an array of user's permissions attributes
How can I help you explore Laravel packages today?