Skip to content

Commit

Permalink
Update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
akiyamaSM committed Jun 7, 2020
1 parent e897876 commit 1d32db0
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,27 @@ Then include the service provider inside `config/app.php`. (You can skipp it if
...
];
```
Publish migrations, and migrate
Publish resources, and migrate

```bash
php artisan vendor:publish
```

You can edit `2020_05_27_221346_add_marvel_id_to_users` migration to link it with the correct user table

PS : You can edit `2020_05_27_221346_add_marvel_id_to_users` migration to link it with the correct user table

And then migrate

```bash
php artisan migrate
```
You will have a `MarvelCan` Middleware, you can tweak it to adapt to your needs and use it such as

```php
// Check if he owns one of those two abilities or both
Route::middleware(['auth:api', 'marvelCan:create_post,edit_post'])
->post('/posts', 'PostsController@store');
```
## Setup a Model

To setup the user model, all you have to do is add (and import) the `IsMarvel` trait.
Expand All @@ -55,8 +63,8 @@ Because every user deserves to be a hero, The Maravel API is based on the Marvel
// Having a user
$user = User::first();

// Create a new marvel
$storm = Spectre::create('storm')->havingPower([
// 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',
Expand Down Expand Up @@ -94,12 +102,14 @@ You can also manage the instances directly

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

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

// Grant the ability
Expand Down

0 comments on commit 1d32db0

Please sign in to comment.