Need help with maravel-permissions?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

137 Stars 5 Forks 9 Commits 0 Opened issues


Because in the Maravelous univer every user deserves super power

Services available


Need anything else?

Contributors list

# 195,264
9 commits

Grant Users the superpower of Marvel characters



composer require inani/maravel-permissions


Then include the service provider inside

. (You can skipp it if it's in Laravel 5.5 or higher)
'providers' => [

Publish resources, and migrate

php artisan vendor:publish

PS : You can edit

migration to link it with the correct user table

And then migrate

php artisan migrate

You will have a

Middleware, you can tweak it to adapt to your needs and use it such as
// Check if he owns one of those two abilities or both
Route::middleware(['auth:api', 'marvelCan:create_post,edit_post'])
      ->post('/posts', '[email protected]');

Setup a Model

To setup the user model, all you have to do is add (and import) the

use Inani\Maravel\IsMarvel;

class User extends Model { use IsMarvel; ... }


All roles are marvel and permissions are powers

Because every user deserves to be a hero, The Maravel API is based on the Marvel Jargon, and here are how it can be used

// Having a user
$user = User::first();

// Create a new marvel, description is not mandotary $storm = Spectre::create('storm', 'A Superhero that can do crazy things')->havingPower([ 'weather_manipulation', 'earth_telepathy', 'high_sens', 'see_the_future' ]);

// 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()->owns('weather_manipulation');

// check if it has one of the provided abilities $user->cerebro()->ownsOneOf([ 'earth_telepathy', 'flying', 'x-ray', ]);

// make it human again (remove its role) $user->cerebro()->humanize();

You can also manage the instances directly ```php

// Create Ability $ability = Ability::create([ 'super_power' => 'speed', 'description' => 'Run faster than anyone else' ]);

// Create a Marvel $marvel = Marvel::create([ 'name' => 'Cristiano Ronaldo', 'description' => 'A super footballer' ]);

// Grant the ability $marvel->grant($ability);

// remove a certain ability $marvel->takeOff($ability);

// remove all and keep only those $marvel->keep($abilities);

// bless it to our user

$user->cerebro()->blessWith($marvel); ```

Am I missing something?

Submit a PR or issue with details!

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.