{"id":22425235,"url":"https://github.com/fireworkweb/laravel-gates","last_synced_at":"2025-09-04T00:06:07.085Z","repository":{"id":38354559,"uuid":"248615762","full_name":"fireworkweb/laravel-gates","owner":"fireworkweb","description":"Permission handling for Laravel using Gates with Route Names","archived":false,"fork":false,"pushed_at":"2024-10-30T19:22:23.000Z","size":35,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-24T12:14:25.889Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fireworkweb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-19T22:16:30.000Z","updated_at":"2025-02-12T16:46:10.000Z","dependencies_parsed_at":"2022-08-24T04:50:43.662Z","dependency_job_id":null,"html_url":"https://github.com/fireworkweb/laravel-gates","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/fireworkweb/laravel-gates","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fireworkweb%2Flaravel-gates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fireworkweb%2Flaravel-gates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fireworkweb%2Flaravel-gates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fireworkweb%2Flaravel-gates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fireworkweb","download_url":"https://codeload.github.com/fireworkweb/laravel-gates/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fireworkweb%2Flaravel-gates/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273529551,"owners_count":25121828,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-05T19:13:35.389Z","updated_at":"2025-09-04T00:06:06.087Z","avatar_url":"https://github.com/fireworkweb.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fireworkweb/laravel-gates\n\n[![Packagist Version](https://img.shields.io/packagist/v/fireworkweb/laravel-gates?style=for-the-badge)](https://packagist.org/packages/fireworkweb/laravel-gates)\n[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/fireworkweb/laravel-gates/run-tests?style=for-the-badge)](https://github.com/fireworkweb/laravel-gates/actions?query=workflow%3Arun-tests)\n[![Codecov](https://img.shields.io/codecov/c/github/fireworkweb/laravel-gates?style=for-the-badge)](https://codecov.io/gh/fireworkweb/laravel-gates)\n[![Scrutinizer code quality (GitHub/Bitbucket)](https://img.shields.io/scrutinizer/quality/g/fireworkweb/laravel-gates?style=for-the-badge)](https://scrutinizer-ci.com/g/fireworkweb/laravel-gates)\n[![Packagist Downloads](https://img.shields.io/packagist/dt/fireworkweb/laravel-gates?style=for-the-badge)](https://packagist.org/packages/fireworkweb/laravel-gates)\n\nThis package allows you to manage permissions using Gates with Route Names.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require fireworkweb/laravel-gates\n```\n\n### Package Middlewares\n\nThis package comes 2 middlewares:\n\n* `Gate` - Checks current route gates, if no matching gate, breaks\n* `GateOptional` - Checks current route gates, if no matching gate, logs\n\nYou can add them inside your `app/Http/Kernel.php` file.\n\n```php\nprotected $routeMiddleware = [\n    // ...\n    'gate' =\u003e \\Fireworkweb\\Gates\\Middlewares\\Gate::class,\n    'gate_optional' =\u003e \\Fireworkweb\\Gates\\Middlewares\\GateOptional::class,\n];\n```\n\n## Usage\n\nHere is an example:\n\n```php\nRoute::middleware('gate')-\u003egroup(function () {\n    // ...\n    Route::get('posts/{post}/edit')-\u003ename('posts.edit');\n});\n```\n\n```php\n\u003c?php\n\nnamespace App\\Policies;\n\nuse App\\Post;\nuse App\\User;\nuse Fireworkweb\\Gates\\Traits\\HasGates;\n\nclass PolicyWithResourceGates\n{\n    use HasGates;\n\n    protected static function gateRouteName() : string\n    {\n        return 'posts';\n    }\n\n    protected static function gateAbilities() : array\n    {\n        return [\n            'edit' =\u003e 'edit',\n        ];\n    }\n\n    public function edit(User $user, Post $post)\n    {\n        return $user-\u003eid === $post-\u003euser_id;\n    }\n}\n```\n\nThat will register a gate `posts.edit` and on route `posts/1/edit` it will check if you on `App\\Policies\\Post@edit` injecting route parameters.\n\n### Commands\n\nYou have commands to help you find routes without gate:\n\n```bash\n# it will get the routes that has `gate` middleware\nfwd artisan gates:routes-without-gate\n\n# in case you are using a custom middleware name or want to check the optional one\nfwd artisan gates:routes-without-gate gate_optional\n```\n\n## Testing\n\n``` bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email contact@fireworkweb.com instead of using the issue tracker.\n\n## Credits\n\n- [Daniel Polito](https://github.com/dbpolito)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffireworkweb%2Flaravel-gates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffireworkweb%2Flaravel-gates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffireworkweb%2Flaravel-gates/lists"}