Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions content/collections/pages/custom-permissions.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,6 +72,29 @@ Permission::register('view blog entries', function ($permission) {

The second argument of the `register` method accepts a closure that allows you to modify the permission.

## Hiding permissions covered by a broader one

Sometimes a broader permission already grants everything a more specific one does — for example, `configure asset containers` already grants every ability `view {container} assets` guards. Rather than show redundant checkboxes for both, you can hide a permission behind one or more others with `hiddenBy`:

``` php
Permission::register('view {container} assets', function ($permission) {
$permission->hiddenBy('configure asset containers');
});
```

When any of the hiding permissions are checked in the roles UI, this permission — and its children — disappear. Unchecking brings them back, with their checked state intact.

You may pass an array to hide a permission behind more than one:

``` php
Permission::register('edit {form} form', function ($permission) {
$permission->hiddenBy(['configure forms', 'edit forms']);
});
```

:::tip
`hiddenBy` only affects the UI. It doesn't grant any permissions or establish a hierarchy — it simply keeps the checkbox out of sight when a broader permission already covers it.
:::

## Policy based permissions

Expand Down