{"id":23577135,"url":"https://github.com/snoeren-development/laravel-admin-users","last_synced_at":"2025-10-10T23:41:26.700Z","repository":{"id":57054381,"uuid":"339469395","full_name":"snoeren-development/laravel-admin-users","owner":"snoeren-development","description":"Define and check for admin users in your application!","archived":false,"fork":false,"pushed_at":"2025-02-26T10:12:52.000Z","size":257,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-05T23:13:33.206Z","etag":null,"topics":["admin","laravel","laravel-package","middleware","php"],"latest_commit_sha":null,"homepage":"","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/snoeren-development.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://bunq.me/SnoerenDevelopment"]}},"created_at":"2021-02-16T17:02:11.000Z","updated_at":"2025-02-26T10:11:30.000Z","dependencies_parsed_at":"2024-11-07T09:23:15.557Z","dependency_job_id":"678b2b20-56f2-4fed-be3e-082c32e0a34c","html_url":"https://github.com/snoeren-development/laravel-admin-users","commit_stats":{"total_commits":32,"total_committers":2,"mean_commits":16.0,"dds":0.0625,"last_synced_commit":"f29f0d6e20dc871c09fb0c05418e0b054d67f38f"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snoeren-development%2Flaravel-admin-users","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snoeren-development%2Flaravel-admin-users/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snoeren-development%2Flaravel-admin-users/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snoeren-development%2Flaravel-admin-users/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snoeren-development","download_url":"https://codeload.github.com/snoeren-development/laravel-admin-users/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252590632,"owners_count":21772940,"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","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":["admin","laravel","laravel-package","middleware","php"],"created_at":"2024-12-26T22:26:43.088Z","updated_at":"2025-10-10T23:41:21.667Z","avatar_url":"https://github.com/snoeren-development.png","language":"PHP","funding_links":["https://bunq.me/SnoerenDevelopment"],"categories":[],"sub_categories":[],"readme":"# Laravel Admin Users\n[![Latest version on Packagist](https://img.shields.io/packagist/v/snoeren-development/laravel-admin-users.svg?style=flat-square)](https://packagist.org/packages/snoeren-development/laravel-admin-users)\n[![Software License](https://img.shields.io/github/license/snoeren-development/laravel-admin-users?style=flat-square)](LICENSE)\n[![Build status](https://img.shields.io/github/actions/workflow/status/snoeren-development/laravel-admin-users/php.yml?branch=main\u0026style=flat-square)](https://github.com/snoeren-development/laravel-admin-users/actions)\n[![Downloads](https://img.shields.io/packagist/dt/snoeren-development/laravel-admin-users?style=flat-square)](https://packagist.org/packages/snoeren-development/laravel-admin-users)\n\nThis small package adds a configuration and user model trait to define\nadministrators within your application.\n\n## Installation\nInstall the package using Composer:\n```bash\ncomposer require snoeren-development/laravel-admin-users\n```\n\n### Requirements\nThis package requires at least PHP 8.2 and Laravel 10.\n\n## Usage\nAdd the `SnoerenDevelopment\\AdminUsers\\Adminable` trait to your user model and\ndefine administrator users using the `ADMINS=` environment variable. The variable\nshould contain a comma separated list of email addresses of your application\nadministrators.\n\n### Using the middleware\nThis package comes with middleware. This middleware checks if the user is an\nadministrator. If not, the middleware throws a 401 unauthorised exception.\n\nAdd the middleware to your `$routeMiddleware` list in the HTTP kernel to use.\n```php\n// Kernel.php\n'admin' =\u003e \\SnoerenDevelopment\\AdminUsers\\AdminMiddleware::class,\n```\n\n### Grant administrators all permissions\n```php\n// AuthServiceProvider.php\n\nuse Illuminate\\Support\\Facades\\Gate;\n\npublic function boot()\n{\n    $this-\u003eregisterPolicies();\n\n    Gate::before(function ($user, $ability) {\n        if ($user-\u003eisAdmin()) {\n            return true;\n        }\n    });\n}\n```\n\n### Using the gate via Blade\n```blade\n{{-- Using the gate via the can-statement. --}}\n@can('admin')\n    The current user is an admin!\n@else\n    The current user is not an admin!\n@endcan\n\n{{-- Using the custom if-statement --}}\n@admin\n    The current user is an admin!\n@else\n    The current user is not an admin!\n@endadmin\n```\n\n### Publishing the configuration file\nYou can publish the configuration file to your project using\n`php artisan vendor:publish`. Then select the admin package.\n\n### Using the MySQL driver\nPublish and run the migration or manually add the `is_admin` column to your users\ntable. Set the driver to `mysql` in your `.env` file using `ADMINS_DRIVER=mysql`.\n\n\n## Testing\n```bash\ncomposer test\n```\n\n## Credits\n- [Michael Snoeren](https://github.com/MSnoeren)\n- [All Contributors](https://github.com/snoeren-development/laravel-admin-users/graphs/contributors)\n\n## License\nThe MIT license. See [LICENSE](LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnoeren-development%2Flaravel-admin-users","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnoeren-development%2Flaravel-admin-users","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnoeren-development%2Flaravel-admin-users/lists"}