PHPackages                             fireworkweb/laravel-gates - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. fireworkweb/laravel-gates

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

fireworkweb/laravel-gates
=========================

Permission handling for Laravel using Gates with Route Names

v0.12(5mo ago)534.7k↓50%2MITPHPPHP ^7.3|^8.0CI passing

Since Mar 19Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/fireworkweb/laravel-gates)[ Packagist](https://packagist.org/packages/fireworkweb/laravel-gates)[ Docs](https://github.com/fireworkweb/laravel-gates)[ RSS](/packages/fireworkweb-laravel-gates/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (3)Versions (14)Used By (0)

fireworkweb/laravel-gates
=========================

[](#fireworkweblaravel-gates)

[![Packagist Version](https://camo.githubusercontent.com/ccdee91d2d69e2ec8bf7a9053d7d816f2fbf1e111ddd47743699973d46f67463/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f66697265776f726b7765622f6c61726176656c2d67617465733f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/fireworkweb/laravel-gates)[![GitHub Workflow Status](https://camo.githubusercontent.com/708335d3d7af6c4164633b8958ac6ef97b3b3c0cb286dfc2b92614c78351d275/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f66697265776f726b7765622f6c61726176656c2d67617465732f72756e2d74657374733f7374796c653d666f722d7468652d6261646765)](https://github.com/fireworkweb/laravel-gates/actions?query=workflow%3Arun-tests)[![Codecov](https://camo.githubusercontent.com/ca44c695502897bf311f77cd9e89a59cd8112089d4a81bb8108a412a883775eb/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f66697265776f726b7765622f6c61726176656c2d67617465733f7374796c653d666f722d7468652d6261646765)](https://codecov.io/gh/fireworkweb/laravel-gates)[![Scrutinizer code quality (GitHub/Bitbucket)](https://camo.githubusercontent.com/eca25fd339d07ef15f1d3ff9171110b065833c1cbe12d6a543fb8ddc3b497a6b/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f7175616c6974792f672f66697265776f726b7765622f6c61726176656c2d67617465733f7374796c653d666f722d7468652d6261646765)](https://scrutinizer-ci.com/g/fireworkweb/laravel-gates)[![Packagist Downloads](https://camo.githubusercontent.com/fd567683d9e9ce499f3c6d2ba65188ecb9b3ae8094329592985443ee2201fb8b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f66697265776f726b7765622f6c61726176656c2d67617465733f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/fireworkweb/laravel-gates)

This package allows you to manage permissions using Gates with Route Names.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require fireworkweb/laravel-gates
```

### Package Middlewares

[](#package-middlewares)

This package comes 2 middlewares:

- `Gate` - Checks current route gates, if no matching gate, breaks
- `GateOptional` - Checks current route gates, if no matching gate, logs

You can add them inside your `app/Http/Kernel.php` file.

```
protected $routeMiddleware = [
    // ...
    'gate' => \Fireworkweb\Gates\Middlewares\Gate::class,
    'gate_optional' => \Fireworkweb\Gates\Middlewares\GateOptional::class,
];
```

Usage
-----

[](#usage)

Here is an example:

```
Route::middleware('gate')->group(function () {
    // ...
    Route::get('posts/{post}/edit')->name('posts.edit');
});
```

```
