Skip to content

Commit

Permalink
Update teams-permissions.md
Browse files Browse the repository at this point in the history
Provide an example of pushing your custom middleware before the SubstituteBindings middleware in the applications middleware stack. In the new Laravel skeleton, this method provides a much cleaner approach than copying all default middlewares in the `bootstrap\app.php` `withMiddleware` method.
  • Loading branch information
WyattCast44 authored Oct 20, 2024
1 parent 43bc084 commit 0562f29
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions docs/basic-usage/teams-permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,34 @@ class TeamsPermission

**YOU MUST ALSO** set [the `$middlewarePriority` array](https://laravel.com/docs/master/middleware#sorting-middleware) in `app/Http/Kernel.php` to include your custom middleware before the `SubstituteBindings` middleware, else you may get *404 Not Found* responses when a *403 Not Authorized* response might be expected.

For example, in Laravel 11.27+ you can add something similiar to the `boot` method of your `AppServiceProvider`.

```php
use App\Http\Middleware\YourCustomMiddlewareClass;
use Illuminate\Foundation\Http\Kernel;
use Illuminate\Routing\Middleware\SubstituteBindings;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
public function register(): void
{
//
}

public function boot(): void
{
/** @var Kernel $kernel */
$kernel = app()->make(Kernel::class);

$kernel->addToMiddlewarePriorityBefore(
SubstituteBindings::class,
YourCustomMiddlewareClass::class,
);
}
}
```

## Roles Creating

When creating a role you can pass the `team_id` as an optional parameter
Expand Down

0 comments on commit 0562f29

Please sign in to comment.