{"id":21344498,"url":"https://github.com/s00d/permissions","last_synced_at":"2025-03-16T03:21:46.971Z","repository":{"id":62538781,"uuid":"47388459","full_name":"s00d/permissions","owner":"s00d","description":"Laravel 5 package for handling user roles and permissions","archived":false,"fork":false,"pushed_at":"2015-12-04T09:03:41.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-03T02:33:59.854Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/s00d.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-04T07:25:47.000Z","updated_at":"2015-12-04T07:30:14.000Z","dependencies_parsed_at":"2022-11-02T16:15:19.187Z","dependency_job_id":null,"html_url":"https://github.com/s00d/permissions","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s00d%2Fpermissions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s00d%2Fpermissions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s00d%2Fpermissions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s00d%2Fpermissions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/s00d","download_url":"https://codeload.github.com/s00d/permissions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243819312,"owners_count":20352868,"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-22T01:19:28.167Z","updated_at":"2025-03-16T03:21:46.953Z","avatar_url":"https://github.com/s00d.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Permissions\n===========\n\nTiny Laravel 5 package for handling user roles and permissions.\n\nInstallation\n============\n\nAdd the following to the require key of your composer.json file:\n\n    \"s00d/permissions\": \"dev-master\"\n    \n        \nRun `$ composer update`.\n\nNavigate to your `config/app.php` file and add `'s00d\\Permissions\\PermissionsServiceProvider'` to the `$providers` array.\n\nCreate the tables by running `$ php artisan migrate package=\"s00d/permissions\"`. Ensure that your `users` table exists first.\n\nNavigate to your `models/User.php` file and add the `s00d\\Permissions\\Can` trait below the class decloration line:\n\n    class User extends Eloquent implements UserInterface, RemindableInterface {\n        use s00d\\Permissions\\Can;\n        \nUsage\n=====\n\nCreate a new role:\n\n    $role = new \\s00d\\Permissions\\Role();\n    $role-\u003ename = 'Administrator';\n    $role-\u003esave();\n    \nCreate a new permission:\n\n    $permission = new \\s00d\\Permissions\\Permission();\n    $permission-\u003ename = 'read_articles';\n    $permission-\u003edisplay_name ='Can read articles';\n    $permission-\u003esave();\n    \nAttach the permission to the role:\n  \n    $role-\u003eallow($permission);\n    \nCreate a user:\n\n    $user = new User;\n    $user-\u003erole_id = 1;\n    $user-\u003esave();\n    \nAnd you're set! To check if a user has a permission:\n\n    $user = User::find(1);\n\n    if ($user-\u003ecan('read_articles'))\n        echo 'The user with the ID of \"1\" can read articles';\n        \nTo check if the current authenticated user has a permission:\n\n    if (Auth::user()-\u003ecan('read_articles'))\n        echo 'The current authenticated user can read articles';\n        \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs00d%2Fpermissions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fs00d%2Fpermissions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs00d%2Fpermissions/lists"}