{"id":21680933,"url":"https://github.com/mooxphp/permission","last_synced_at":"2025-03-20T10:30:24.447Z","repository":{"id":253271082,"uuid":"842816197","full_name":"mooxphp/permission","owner":"mooxphp","description":"[READ-ONLY] Roles and Permissions for Filament, Moox and Laravel","archived":false,"fork":false,"pushed_at":"2025-03-13T13:37:52.000Z","size":33,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-18T16:57:39.769Z","etag":null,"topics":[],"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/mooxphp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["mooxphp"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2024-08-15T06:34:37.000Z","updated_at":"2025-03-13T13:37:56.000Z","dependencies_parsed_at":"2024-11-25T15:38:12.075Z","dependency_job_id":null,"html_url":"https://github.com/mooxphp/permission","commit_stats":null,"previous_names":["mooxphp/permission"],"tags_count":0,"template":false,"template_full_name":"mooxphp/builder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mooxphp%2Fpermission","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mooxphp%2Fpermission/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mooxphp%2Fpermission/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mooxphp%2Fpermission/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mooxphp","download_url":"https://codeload.github.com/mooxphp/permission/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244594676,"owners_count":20478329,"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":[],"created_at":"2024-11-25T15:22:42.313Z","updated_at":"2025-03-20T10:30:24.425Z","avatar_url":"https://github.com/mooxphp.png","language":"PHP","readme":"![Moox Permission](https://github.com/mooxphp/moox/raw/main/art/banner/permission.jpg)\n\n# Moox Permission\n\nThis is my package permission\n\n## Quick Installation\n\nThese two commmands are all you need to install the package:\n\n```bash\ncomposer require moox/permission\nphp artisan mooxpermission:install\n```\n\nCurious what the install command does? See manual installation below.\n\n## What it does\n\n\u003c!--whatdoes--\u003e\n\nHere are some things missing, like an overview with screenshots about this package, or simply a link to the package's docs.\n\n\u003c!--/whatdoes--\u003e\n\n## Manual Installation\n\nInstead of using the install-command `php artisan mooxpermission:install` you are able to install this package manually step by step:\n\n```bash\n// Publish and run the migrations:\nphp artisan vendor:publish --tag=\"permission-migrations\"\nphp artisan migrate\n\n// Publish the config file with:\nphp artisan vendor:publish --tag=\"permission-config\"\n```\n\n## Using the Default Policy\n\nThe default policy handles all defaults for Moox Resources in Filament:\n\n```php\n\u003c?php\n\nnamespace Moox\\Permission\\Policies;\n\nuse App\\Models\\User;\n\nclass DefaultPolicy\n{\n    public function viewAll(User $user)\n    {\n        return $user-\u003ehasPermissionTo('view all');\n    }\n\n    public function editAll(User $user)\n    {\n        return $user-\u003ehasPermissionTo('edit all');\n    }\n\n    public function deleteAll(User $user)\n    {\n        return $user-\u003ehasPermissionTo('delete all');\n    }\n\n    public function create(User $user)\n    {\n        return $user-\u003ehasPermissionTo('create');\n    }\n\n    public function viewOwn(User $user, $model)\n    {\n        return $user-\u003ehasPermissionTo('view own') \u0026\u0026 $model-\u003euser_id === $user-\u003eid;\n    }\n\n    public function editOwn(User $user, $model)\n    {\n        return $user-\u003ehasPermissionTo('edit own') \u0026\u0026 $model-\u003euser_id === $user-\u003eid;\n    }\n\n    public function deleteOwn(User $user, $model)\n    {\n        return $user-\u003ehasPermissionTo('delete own') \u0026\u0026 $model-\u003euser_id === $user-\u003eid;\n    }\n\n    public function emptyTrash(User $user)\n    {\n        return $user-\u003ehasPermissionTo('empty trash');\n    }\n\n    public function changeSettings(User $user)\n    {\n        return $user-\u003ehasPermissionTo('change settings');\n    }\n}\n```\n\nThe default policy is used by most Moox packages.\n\nIf you use Moox Builder to create a package, the default policy works out of the box and all default permissions are pre-configured to sane defaults.\n\n## Extending the Default Policy\n\nIf you need to create a policy for a specific resource, you can extend the DefaultPolicy and override any methods where custom logic is required.\n\n```php\nuse Moox\\Permission\\Policies\\DefaultPolicy;\n\nclass ItemPolicy extends DefaultPolicy\n{\n    // Custom logic for editing own items\n    public function editOwn(User $user, $item)\n    {\n        // Maybe add additional checks here\n        return parent::editOwn($user, $item);\n    }\n\n    // Additional custom methods if needed\n}\n\n```\n\nYou then need to register the policy in the published Moox Core config (/config/core.php):\n\n```php\nreturn [\n    'packages' =\u003e [\n        'audit' =\u003e [\n            'package' =\u003e 'Moox Audit',\n            'models' =\u003e [\n                'Audit' =\u003e [\n                    'policy' =\u003e \\Moox\\Audit\\Policies\\AuditPolicy::class,\n                ],\n            ],\n        ],\n        // more packages\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](https://github.com/mooxphp/moox/security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n-   [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","funding_links":["https://github.com/sponsors/mooxphp"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmooxphp%2Fpermission","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmooxphp%2Fpermission","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmooxphp%2Fpermission/lists"}