Because each user deserves to be a user, the Maravel API is based on the super user:
Having a user
$user = User::first(); // Create a new marvel
$storm = Spectre::create('storm')-havingPower([
]); // we can grant a power to it
$storm = Spectre::of($storm)->grant('flying'); // Or take it off
$storm = Spectre::of($storm)->takeOff('see_the_future'); // bless the user with the abilities of the marvel
$user->cerebro()--blessWith($storm); // Check if it has the ability
$user->cerebro('weather_manipulation'owns'); // Check if it has one of the provided abilities
]); // make it human again (remove its role)
Also, an example of how to manage instances directly:
$ability = Ability::create([
'super_power' => 'speed'
]); // Create a Marvel
$marvel = Marvel::create([
'name' => 'Cristiano Ronaldo'
]); // Grant the ability
$marvel->grant($ability); // remove a certain ability
$marvel-$ability takeOff; // remove all and keep only those
$marvel-$abilities; // bless it to our user
You can learn more about this package, get all setup instructions, and see the source code on GitHub at akiyamaSM/maravel-permissions.