Skip to content

Commit

Permalink
format README
Browse files Browse the repository at this point in the history
  • Loading branch information
uwla committed Apr 29, 2023
1 parent 7cf6c04 commit 8ae5c63
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ class Article extends Model implements PermissionableContract
Here is a summary of the auxilary methods provided by `Permissionable`:

| Name | Description |
| :------------------------- | :---------------------------------------------------------------------------- |
| :------------------------- | :--------------------------------------------------------------------------------- |
| `createViewPermission` | Create permission for viewing the model. |
| `createUpdatePermission` | Create permission for updating the model. |
| `createDeletePermission` | Create permission for deleting the model. |
Expand Down Expand Up @@ -391,7 +391,7 @@ Attach the permissions to the user:

```php
<?php
// while you could fetch the permissions manually and then attach it to the user or role
// you can fetch the permissions manually and then attach it to the user or role
$viewPermission = $article->getViewPermission();
$role->addPermission($viewPermission); // assign to a role
$user->addPermission($viewPermission); // assign to a specific user
Expand All @@ -400,7 +400,7 @@ $crudPermissions = $article->getCrudPermissions();
$user->addPermissions($crudPermissions);
$role->addPermissions($crudPermissions);

// it is easier to attach them via the model
// but it is easier to attach them via the model
$article->attachViewPermission($role);
$article->attachViewPermission($user);

Expand Down Expand Up @@ -467,13 +467,14 @@ with the `Permissionable` trait.
$model->deletetThisModelPermissions();
```

If you want that behavior to be triggered automatically before deleting an Eloquent
model, you can add that to the `boot` method of your model:
If you want that behavior to be triggered automatically before deleting an
Eloquent model, you can add that to the `boot` method of your model:

```php
<?php
/*
* Register callback to delete permissions associated with this model when it gets deleted.
* Register callback to delete permissions associated with this model when it
* gets deleted.
*
* @return void
*/
Expand Down Expand Up @@ -564,8 +565,8 @@ $articles = $user->getModels(Article::class);
$articles = $role->getModels(Article::class);
```

This will fetch all `Article` models such that there is a per-model permission
associated with them and the user or role has access to at least one of such
This will fetch all `Article` models such that there is a per-model permission
associated with them and the user or role has access to at least one of such
per-model permissions.

You can specify the name of the permission too:
Expand Down

0 comments on commit 8ae5c63

Please sign in to comment.