├── .editorconfig ├── .github ├── config.yml ├── dependabot.yml ├── issue_template.md ├── pull_request_template.md ├── release-drafter.yml ├── stale.yml ├── support.yml └── workflows │ └── add-to-project.yml ├── .gitignore ├── .scrutinizer.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── composer.json └── src ├── PermissionManagerServiceProvider.php ├── app ├── Http │ ├── Controllers │ │ ├── PermissionCrudController.php │ │ ├── RoleCrudController.php │ │ └── UserCrudController.php │ └── Requests │ │ ├── PermissionStoreCrudRequest.php │ │ ├── PermissionUpdateCrudRequest.php │ │ ├── RoleStoreCrudRequest.php │ │ ├── RoleUpdateCrudRequest.php │ │ ├── UserStoreCrudRequest.php │ │ └── UserUpdateCrudRequest.php └── Models │ ├── Permission.php │ └── Role.php ├── config └── backpack │ └── permissionmanager.php ├── database └── migrations │ └── 2020_03_31_114745_remove_backpackuser_model.php ├── resources └── lang │ ├── ar │ └── permissionmanager.php │ ├── da_DK │ └── permissionmanager.php │ ├── de │ └── permissionmanager.php │ ├── el │ └── permissionmanager.php │ ├── en │ └── permissionmanager.php │ ├── es │ └── permissionmanager.php │ ├── fr │ └── permissionmanager.php │ ├── fr_CA │ └── permissionmanager.php │ ├── hu │ └── permissionmanager.php │ ├── id │ └── permissionmanager.php │ ├── it │ └── permissionmanager.php │ ├── ja │ └── permissionmanager.php │ ├── lv │ └── permissionmanager.php │ ├── nl │ └── permissionmanager.php │ ├── pt │ └── permissionmanager.php │ ├── pt_br │ └── permissionmanager.php │ ├── ru │ └── permissionmanager.php │ ├── sr │ └── permissionmanager.php │ ├── tr │ └── permissionmanager.php │ ├── uk │ └── permissionmanager.php │ ├── vi │ └── permissionmanager.php │ ├── zh-Hant │ └── permissionmanager.php │ └── zh-cn │ └── permissionmanager.php └── routes └── backpack └── permissionmanager.php /.editorconfig: -------------------------------------------------------------------------------- 1 | ; This file is for unifying the coding style for different editors and IDEs. 2 | ; More information at http://editorconfig.org 3 | 4 | root = true 5 | 6 | [*] 7 | charset = utf-8 8 | indent_size = 4 9 | indent_style = space 10 | end_of_line = lf 11 | insert_final_newline = true 12 | trim_trailing_whitespace = true 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | -------------------------------------------------------------------------------- /.github/config.yml: -------------------------------------------------------------------------------- 1 | # Configuration for welcome - https://github.com/behaviorbot/welcome 2 | 3 | # Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome 4 | 5 | # Comment to be posted to on first time issues 6 | newIssueWelcomeComment: > 7 | Hello there! Thanks for opening your first issue on this repo! 8 | 9 | 10 | Just a heads-up: **Here at Backpack we use Github Issues only for tracking bugs**. Talk about new features is also acceptable. This helps _a lot_ in keeping our focus on improving Backpack. **If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below)**. If you're not sure where it fits, it's ok, a community member will probably reply to help you with that. 11 | 12 | 13 | Backpack communication mediums: 14 | - Bug Reports, Feature Requests - Github Issues (here); 15 | - Quick help (_How do I do X_) - [Gitter Chatroom](https://gitter.im/BackpackForLaravel/Lobby); 16 | - Long questions (_I have done X and Y and it won't do Z wtf_) - [Stackoverflow](https://stackoverflow.com/questions/tagged/backpack-for-laravel), using the ```backpack-for-laravel``` tag; 17 | 18 | 19 | Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome _awesome_ community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch. 20 | 21 | 22 | Thank you! 23 | 24 | 25 | -- 26 | 27 | Justin Case 28 | 29 | The Backpack Robot 30 | 31 | # Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome 32 | 33 | # Comment to be posted to on PRs from first time contributors in your repository 34 | newPRWelcomeComment: > 35 | BOOM! Your first PR with us, thank you so much! Someone will take a look at it shortly. 36 | 37 | 38 | Please keep in mind that: 39 | - **if this constitutes a breaking change, it might take quite a while for this to get merged**; we try to emulate the Laravel release cycle as much as possible, so developers can upgrade both software once; this means a new big release every ~6 months; 40 | - **even if it's a non-breaking change, it might take a few days/weeks for the PR to get merged**; unless it's a no-brainer, **we like to have some community feedback on new features, before we merge them**; this leads to higher-quality code, in the end; we learnt this the hard way :-) 41 | - **not all PRs get merged**; sometimes we just have to hold out new features, to keep the packages lean; sometimes we don't include features that only apply to niche use cases; 42 | - **we're not perfect**; if you think we're wrong, call us out on it; but in a kind way :-) we all make mistakes, best we learn from them and build better software together; 43 | 44 | 45 | Thank you! 46 | 47 | 48 | -- 49 | 50 | Justin Case 51 | 52 | The Backpack Robot 53 | 54 | # Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge 55 | 56 | # Comment to be posted to on pull requests merged by a first time user 57 | firstPRMergeComment: > 58 | WHOOP-WHOOP! Congrats, your first PR on this repo has officialy been merged. 59 | 60 | 61 | ![party](https://media1.giphy.com/media/3KC2jD2QcBOSc/giphy.gif "Party!!!") 62 | 63 | 64 | If you want to help out the community in other ways, you can: 65 | - **give your opinion on other Github Issues & PRs**; 66 | - **chat with others** in the [Gitter Chatroom](https://gitter.im/BackpackForLaravel/Lobby) (usually for quick help: _How do I do X_); 67 | - **answer Backpack questions on [Stackoverflow](https://stackoverflow.com/questions/tagged/backpack-for-laravel)**; you get points, people get help; you can subscribe to the ```backpack-for-laravel``` tag by [adding a new filter](https://stackexchange.com/filters/256210/my-filter-3); that will send you emails when new questions come up with our tag; 68 | 69 | 70 | Again. Thank you for the PR. You are a wonderful person. Keep 'em coming :-) 71 | 72 | Cheers! 73 | 74 | 75 | -- 76 | 77 | Justin Case 78 | 79 | The Backpack Robot 80 | 81 | 82 | P.S. **Help in the Backpack community is rewarded with free Backpack commercial licenses**. It's the least we can do. If you feel you've helped the community with PRs, help & other stuff, please [shoot Tabacitu an email](mailto:hello@tabacitu.ro) and ask him if you qualify for free licenses. You scratch my back, I scratch your back. Thank you! 83 | 84 | # It is recommend to include as many gifs and emojis as possible 85 | # 86 | # --------------------------------------------------------------------------------------------- 87 | # 88 | # Configuration for request-info - https://github.com/behaviorbot/request-info 89 | 90 | # *OPTIONAL* Comment to reply with 91 | # Can be either a string : 92 | requestInfoReplyComment: > 93 | Hi there! 94 | 95 | 96 | Could you please provide us with more info about this? Looks like you skipped the title/body. 97 | 98 | 99 | Thank you! 100 | 101 | 102 | -- 103 | 104 | Justin Case 105 | 106 | The Backpack Robot 107 | 108 | # Or an array: 109 | # requestInfoReplyComment: 110 | # - Ah no! young blade! That was a trifle short! 111 | # - Tell me more ! 112 | # - I am sure you can be more effusive 113 | 114 | 115 | # *OPTIONAL* default titles to check against for lack of descriptiveness 116 | # MUST BE ALL LOWERCASE 117 | requestInfoDefaultTitles: 118 | # - update readme.md 119 | - updates 120 | 121 | # *OPTIONAL* Label to be added to Issues and Pull Requests with insufficient information given 122 | requestInfoLabelToAdd: needs-more-info 123 | 124 | # *OPTIONAL* Only warn about insufficient information on these events type 125 | # Keys must be lowercase. Valid values are 'issue' and 'pullRequest' 126 | requestInfoOn: 127 | pullRequest: true 128 | issue: true 129 | 130 | # *OPTIONAL* Add a list of people whose Issues/PRs will not be commented on 131 | # keys must be GitHub usernames 132 | requestInfoUserstoExclude: 133 | - tabacitu 134 | 135 | # --------------------------------------------------------------------------------------------- 136 | # 137 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: composer 4 | directory: "/" 5 | schedule: 6 | interval: monthly 7 | open-pull-requests-limit: 10 8 | ignore: 9 | - dependency-name: spatie/laravel-permission 10 | versions: 11 | - 4.0.0 12 | -------------------------------------------------------------------------------- /.github/issue_template.md: -------------------------------------------------------------------------------- 1 | # Bug report 2 | 3 | ### What I did: 4 | 5 | ### What I expected to happen: 6 | 7 | ### What happened: 8 | 9 | ### What I've already tried to fix it: 10 | 11 | ### Backpack, Laravel, PHP, DB version: 12 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## WHY 2 | 3 | ### BEFORE - What was wrong? What was happening before this PR? 4 | 5 | ?? 6 | 7 | ### AFTER - What is happening after this PR? 8 | 9 | ?? 10 | 11 | 12 | ## HOW 13 | 14 | ### How did you achieve that, in technical terms? 15 | 16 | ?? 17 | 18 | 19 | 20 | ### Is it a breaking change or non-breaking change? 21 | 22 | ?? 23 | 24 | 25 | ### How can we test the before & after? 26 | 27 | ?? 28 | -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | 3 | on: 4 | push: 5 | # branches to consider in the event; optional, defaults to all 6 | branches: 7 | - master 8 | - 4.1 9 | 10 | jobs: 11 | update_release_draft: 12 | runs-on: ubuntu-latest 13 | steps: 14 | # Drafts your next Release notes as Pull Requests are merged into "master" 15 | - uses: release-drafter/release-drafter@v5 16 | env: 17 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 18 | 19 | name-template: '$NEXT_PATCH_VERSION 🌈' 20 | tag-template: '$NEXT_PATCH_VERSION' 21 | categories: 22 | - title: '🚀 Features' 23 | labels: 24 | - 'feature' 25 | - 'enhancement' 26 | - 'added' 27 | - title: '🐛 Bug Fixes' 28 | labels: 29 | - 'fix' 30 | - 'bugfix' 31 | - 'bug' 32 | - 'fixed' 33 | - title: '⚙️ Changes' 34 | labels: 35 | - 'changed' 36 | - 'dependencies' 37 | - title: '🧰 Removed' 38 | label: 'removed' 39 | change-template: '- $TITLE @$AUTHOR (#$NUMBER)' 40 | template: | 41 | $CHANGES 42 | 43 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | ##################################### 2 | # Github Stale Probot Configuration # 3 | # ################################### 4 | # https://probot.github.io/apps/stale/ 5 | 6 | # Number of days of inactivity before an issue becomes stale 7 | daysUntilStale: 60 8 | # Number of days of inactivity before a stale issue is closed 9 | daysUntilClose: 14 10 | # Issues with these labels will never be considered stale 11 | exemptLabels: 12 | - pinned 13 | - security 14 | - feature 15 | - urgent 16 | - ready 17 | - working on it 18 | - bug 19 | 20 | # Label to use when marking an issue as stale 21 | staleLabel: stale 22 | # Comment to post when marking an issue as stale. Set to `false` to disable 23 | markComment: > 24 | Hi there! 25 | 26 | 27 | **Is this still an issue?** No activity in 60 days. I'm going to mark it as stale for now, and close it in 14 days if no further activity occurs. I know you guys are all busy, but if this is important to you please reply or something, so I know not to close it. 28 | 29 | 30 | Thank you! 31 | 32 | 33 | -- 34 | 35 | Justin Case 36 | 37 | The Backpack Robot 38 | 39 | # Comment to post when closing a stale issue. Set to `false` to disable 40 | closeComment: true 41 | -------------------------------------------------------------------------------- /.github/support.yml: -------------------------------------------------------------------------------- 1 | # Configuration for support-requests - https://github.com/dessant/support-requests 2 | 3 | # Label used to mark issues as support requests 4 | supportLabel: Ask-It-On-Stack-Overflow 5 | # Comment to post on issues marked as support requests. Add a link 6 | # to a support page, or set to `false` to disable 7 | supportComment: > 8 | Oups! 9 | 10 | 11 | Looks like this is a support request, not a bug/feature. **Could you please [repost on StackOverflow](https://stackoverflow.com/questions/tagged/backpack-for-laravel), using the ```backpack-for-laravel``` tag**? 12 | 13 | 14 | Background: **Here at Backpack we use Github Issues only for tracking bugs and features**, not individual implementation issues. This helps _a lot_ in keeping our focus on improving Backpack. Thanks a lot for understanding! 15 | 16 | 17 | Here are all the Backpack communication mediums: 18 | - Long questions (_I have done X and Y and it won't do Z wtf_) - [Stackoverflow](https://stackoverflow.com/questions/tagged/backpack-for-laravel), using the ```backpack-for-laravel``` tag; this is recommended for most questions, since other developers can then find the answer on a simple Google search; also, people get points for answering - and who doesn't like StackOverflow points?! 19 | - Quick help (_How do I do X_) - [Gitter Chatroom](https://gitter.im/BackpackForLaravel/Lobby); 20 | - Bug Reports, Feature Requests - Github Issues (here); 21 | 22 | Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or StackOverflow is thanks to our awesome _awesome_ community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch. 23 | 24 | 25 | Thank you! 26 | 27 | 28 | -- 29 | 30 | Justin Case 31 | 32 | The Backpack Robot 33 | 34 | 35 | PS. In case I mistakenly closed your issue, yell :-) I'm a robot, I make mistakes. 36 | 37 | # Whether to close issues marked as support requests 38 | close: true 39 | # Whether to lock issues marked as support requests 40 | lock: false 41 | -------------------------------------------------------------------------------- /.github/workflows/add-to-project.yml: -------------------------------------------------------------------------------- 1 | name: Add new bugs & PRs to This Week project 2 | 3 | on: 4 | issues: 5 | types: 6 | - opened 7 | - transferred 8 | pull_request: 9 | types: 10 | - opened 11 | 12 | jobs: 13 | add-to-project: 14 | name: Add new bugs and PRs to This Week project 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/add-to-project@main 18 | with: 19 | project-url: https://github.com/orgs/Laravel-Backpack/projects/13 20 | github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | vendor/ 3 | node_modules/ 4 | .DS_Store 5 | .composer.lock 6 | composer.lock 7 | .phpunit.result.cache -------------------------------------------------------------------------------- /.scrutinizer.yml: -------------------------------------------------------------------------------- 1 | filter: 2 | paths: 3 | - 'app/*' 4 | - 'src/*' 5 | excluded_paths: 6 | - 'bootstrap/*' 7 | - 'config/*' 8 | - 'public/*' 9 | - 'resources/*' 10 | - 'vendor/*' 11 | - 'views/*' 12 | tools: 13 | php_analyzer: true 14 | php_mess_detector: true 15 | php_changetracking: true 16 | php_code_sniffer: 17 | config: 18 | standard: PSR2 19 | php_loc: 20 | excluded_dirs: 21 | - vendor 22 | php_pdepend: 23 | excluded_dirs: 24 | - vendor 25 | - tests 26 | checks: 27 | php: 28 | code_rating: true 29 | duplication: true 30 | variable_existence: true 31 | useless_calls: true 32 | use_statement_alias_conflict: true 33 | unused_variables: true 34 | unused_properties: true 35 | unused_parameters: true 36 | unused_methods: true 37 | unreachable_code: true 38 | sql_injection_vulnerabilities: true 39 | security_vulnerabilities: true 40 | precedence_mistakes: true 41 | precedence_in_conditions: true 42 | parameter_non_unique: true 43 | no_property_on_interface: true 44 | no_non_implemented_abstract_methods: true 45 | deprecated_code_usage: true 46 | closure_use_not_conflicting: true 47 | closure_use_modifiable: true 48 | avoid_useless_overridden_methods: true 49 | avoid_conflicting_incrementers: true 50 | assignment_of_null_return: true 51 | verify_property_names: true 52 | verify_argument_usable_as_reference: true 53 | verify_access_scope_valid: true 54 | use_self_instead_of_fqcn: true 55 | too_many_arguments: true 56 | symfony_request_injection: true 57 | switch_fallthrough_commented: true 58 | spacing_of_function_arguments: true 59 | spacing_around_non_conditional_operators: true 60 | spacing_around_conditional_operators: true 61 | space_after_cast: true 62 | single_namespace_per_use: true 63 | simplify_boolean_return: true 64 | scope_indentation: 65 | spaces_per_level: '4' 66 | return_doc_comments: true 67 | require_scope_for_properties: true 68 | require_scope_for_methods: true 69 | require_php_tag_first: true 70 | require_braces_around_control_structures: true 71 | remove_trailing_whitespace: true 72 | remove_php_closing_tag: true 73 | remove_extra_empty_lines: true 74 | psr2_switch_declaration: true 75 | psr2_control_structure_declaration: true 76 | psr2_class_declaration: true 77 | property_assignments: true 78 | properties_in_camelcaps: true 79 | prefer_while_loop_over_for_loop: true 80 | phpunit_assertions: true 81 | php5_style_constructor: true 82 | parameters_in_camelcaps: true 83 | parameter_doc_comments: true 84 | return_doc_comment_if_not_inferrable: true 85 | param_doc_comment_if_not_inferrable: true 86 | overriding_private_members: true 87 | optional_parameters_at_the_end: true 88 | one_class_per_file: true 89 | non_commented_empty_catch_block: true 90 | no_unnecessary_if: true 91 | no_unnecessary_function_call_in_for_loop: true 92 | no_unnecessary_final_modifier: true 93 | no_underscore_prefix_in_properties: true 94 | no_underscore_prefix_in_methods: true 95 | no_trailing_whitespace: true 96 | no_space_inside_cast_operator: true 97 | no_space_before_semicolon: true 98 | no_space_around_object_operator: true 99 | no_goto: true 100 | no_global_keyword: true 101 | no_exit: true 102 | no_empty_statements: true 103 | no_else_if_statements: true 104 | no_duplicate_arguments: true 105 | no_debug_code: true 106 | no_commented_out_code: true 107 | newline_at_end_of_file: true 108 | naming_conventions: 109 | local_variable: '^[a-z][a-zA-Z0-9]*$' 110 | abstract_class_name: ^Abstract|Factory$ 111 | utility_class_name: 'Utils?$' 112 | constant_name: '^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$' 113 | property_name: '^[a-z][a-zA-Z0-9]*$' 114 | method_name: '^(?:[a-z]|__)[a-zA-Z0-9]*$' 115 | parameter_name: '^[a-z][a-zA-Z0-9]*$' 116 | interface_name: '^[A-Z][a-zA-Z0-9]*Interface$' 117 | type_name: '^[A-Z][a-zA-Z0-9]*$' 118 | exception_name: '^[A-Z][a-zA-Z0-9]*Exception$' 119 | isser_method_name: '^(?:is|has|should|may|supports|was)' 120 | lowercase_php_keywords: true 121 | more_specific_types_in_doc_comments: true 122 | missing_arguments: true 123 | method_calls_on_non_object: true 124 | line_length: 125 | max_length: '120' 126 | lowercase_basic_constants: true 127 | instanceof_class_exists: true 128 | function_in_camel_caps: true 129 | function_body_start_on_new_line: true 130 | fix_use_statements: 131 | remove_unused: true 132 | preserve_multiple: false 133 | preserve_blanklines: false 134 | order_alphabetically: true 135 | foreach_traversable: true 136 | foreach_usable_as_reference: true 137 | fix_php_opening_tag: true 138 | fix_line_ending: true 139 | fix_identation_4spaces: true 140 | fix_doc_comments: true 141 | ensure_lower_case_builtin_functions: true 142 | encourage_postdec_operator: true 143 | classes_in_camel_caps: true 144 | catch_class_exists: true 145 | blank_line_after_namespace_declaration: true 146 | avoid_usage_of_logical_operators: true 147 | avoid_unnecessary_concatenation: true 148 | avoid_tab_indentation: true 149 | avoid_superglobals: true 150 | avoid_perl_style_comments: true 151 | avoid_multiple_statements_on_same_line: true 152 | avoid_fixme_comments: true 153 | avoid_length_functions_in_loops: true 154 | avoid_entity_manager_injection: true 155 | avoid_duplicate_types: true 156 | avoid_corrupting_byteorder_marks: true 157 | argument_type_checks: true 158 | avoid_aliased_php_functions: true 159 | deadlock_detection_in_loops: true 160 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All Notable changes to `Backpack PermissionManager` will be documented in this file 4 | 5 | ---------- 6 | IMPORTANT 7 | ---------- 8 | 9 | Since version 6.0.0, we no longer use this file to track changes. Please see our Releases tab on Github: 10 | https://github.com/Laravel-Backpack/PermissionManager/releases 11 | 12 | ---------- 13 | 14 | ## 5.0.7 - 2020-03-05 15 | 16 | ### Fixed 17 | - upgraded PHPUnit to 9/7; 18 | 19 | 20 | ## 5.0.6 - 2020-01-15 21 | 22 | ### Fixed 23 | - merged #216 - translated labels for filters in UserCrudController; 24 | 25 | 26 | ## 5.0.5 - 2020-01-14 27 | 28 | ### Fixed 29 | - packagist merge issue; 30 | 31 | 32 | ## 5.0.4 - 2020-01-14 33 | 34 | ### Added 35 | - merged #218 - added Indonesian language file; 36 | 37 | 38 | ## 5.0.3 - 2019-12-24 39 | 40 | ### Added 41 | - Added filters to the Users CRUD: Role and Extra Permission 42 | 43 | ### Fixed 44 | - Refactored Roles and Permissions CRUDs to use methods for setting up operations, instead of on() closures; 45 | - Added validation and required asterisks to Create and Update operations on Roles and Permissions CRUDs; 46 | 47 | 48 | ## 5.0.2 - 2019-10-19 49 | 50 | ### Added 51 | - Arabic translation; 52 | 53 | 54 | ## 5.0.1 - 2019-10-04 55 | 56 | ### Fixed 57 | - User update operation works when route prefix is set to empty string; 58 | 59 | 60 | ## 5.0.0 - 2019-09-24 61 | 62 | ### Added 63 | - support for Backpack v4; 64 | 65 | ### Removed 66 | - support for Backpack v3; 67 | 68 | 69 | ----- 70 | 71 | 72 | ## [4.0.6] - 2019-09-04 73 | 74 | ### Added 75 | - upgraded to spatie/laravel-permission version 3.x, that provides support for Laravel 6; 76 | 77 | 78 | ## [4.0.5] - 2019-08-14 79 | 80 | ### Fixed 81 | - UserUpdateCrudRequest had a theoretical vulnerability by not validating the ID before using it in the rule; it's now double-checked beforehand; 82 | - Fixes #126 - array to string conversion; 83 | - Fixes #196 - allows uses of other encryption mechanisms beside bcrypt; 84 | 85 | 86 | ## [4.0.4] - 2019-03-12 87 | 88 | ### Fixed 89 | - can be installed with point versions of spatie/laravel-permission; 90 | 91 | 92 | 93 | ## [4.0.3] - 2019-03-12 94 | 95 | ### Added 96 | - merged #185 - added Serbian language; 97 | 98 | 99 | ## [4.0.2] - 2019-03-12 100 | 101 | ### Added 102 | - proper validation messages when trying to add a role or permission that exists; 103 | 104 | 105 | ## [4.0.1] - 2019-02-27 106 | 107 | ### Added 108 | - support for the ```upgrade``` branch for Backpack\CRUD, so it can be installed temporarily with Laravel 5.8; 109 | - requirement for latest version of spatie/laravel-permission, 2.34; 110 | 111 | 112 | ## [4.0.0] - 2018-12-12 113 | 114 | ### Added 115 | - support for spatie/laravel-permission version 2.28.1; 116 | - ability to specify guards when creating/updating roles and permissions; config option to turn that on and off (default: false); 117 | 118 | ### Removed 119 | - config file for spatie/laravel-permission; models being used in CRUDs are now defined in ```config/backpack/permissionmanager.php```; 120 | - migrations, since they are provided by spatie/laravel-permission; 121 | 122 | 123 | ## [3.12.6] - 2018-10-16 124 | 125 | ### Fixed 126 | - validation for unique email when updating a user; 127 | 128 | 129 | ## [3.12.5] - 2018-09-29 130 | 131 | ### Added 132 | - #171 - French Canadian translation; 133 | 134 | 135 | ## [3.12.4] - 2018-06-26 136 | 137 | ### Fixed 138 | - #162 - use Request for changing password instead of deprecated CrudRequest; 139 | 140 | 141 | ## [3.12.2] - 2018-06-21 142 | 143 | ### Added 144 | - #160 - use custom Backpack guard as per Backpack\Base 0.9.x; 145 | 146 | ## [3.12.1] - 2018-06-19 147 | 148 | ### Added 149 | - #159 - Italian translation, thanks to [Roberto Butti](https://github.com/roberto-butti); 150 | 151 | 152 | ## [3.12.0] - 2018-06-07 153 | 154 | ### Added 155 | - support for ```spatie/laravel-permission``` v2.12; 156 | 157 | ### Removed 158 | - support for ```spatie/laravel-permission``` v2.12; 159 | 160 | ### Notes 161 | - the db structure has changed; because that's what spatie did between v1.4 and v2.12; 162 | - there is no upgrade guide from spatie v1 to spatie v2; and after spending a lot of time on this, I understand why; it would have been way to difficult to create migrations for such an upgrade; especially for big projects, that might have other foreign keys to/from the old tables; 163 | - as such, we didn't provide an upgrade guide either; people who use v1 will continue to use v1; people who start now will be using v2; 164 | - if we do go through the upgrade ourselves at one point, we might provide an upgrade guide; if anybody, ever, creates an upgrade guide, please link to it on the README; 165 | - since spatie/laravel-permission pushes breaking changes like crazy, and this package is pretty simple and does not need regular updates, I've decided to track spatie/laravel-permission's version; starting now; this new version will be 3.12 because it uses spatie/laravel-permission v2.12; 166 | 167 | --------------------- 168 | 169 | ## [2.1.27] - 2018-05-02 170 | 171 | ### Added 172 | - support for Backpack\CRUD 3.4; 173 | 174 | ### Fixed 175 | - routes are now using the ```backpack_middleware()``` instead of hardcoded ```admin```; merges #151; 176 | 177 | ### Removed 178 | - support for Backpack\CRUD 3.3 (since we're using the new middleware); 179 | 180 | 181 | ## [2.1.26] - 2018-03-13 182 | 183 | ## Added 184 | - German translation; 185 | - Latvian translation; 186 | - French translation; 187 | 188 | 189 | ## [2.1.25] - 2018-03-13 190 | 191 | ## Fixed 192 | - #148 using custom Permission and Role models for fields and columns, as defined in the ```laravel-permission.php``` config file; 193 | 194 | 195 | ## [2.1.24] - 2017-12-13 196 | 197 | ## Fixed 198 | - Clear cache key spatie.permission.cache, otherwise, changes won't have effect - merged #114; 199 | 200 | 201 | ## [2.1.23] - 2017-12-13 202 | 203 | ## Fixed 204 | - "Class CRUD not found" when autodiscovery feature got the wrong package order - merged #133; 205 | 206 | 207 | ## [2.1.22] - 2017-12-02 208 | 209 | ## Added 210 | - removed PHP 5.6 from travis.yml 211 | 212 | 213 | ## [2.1.21] - 2017-12-02 214 | 215 | ## Added 216 | - CRUD 3.3 requirement in composer; 217 | 218 | 219 | ## [2.1.20] - 2017-12-02 220 | 221 | ## Added 222 | - package auto-discovery; 223 | 224 | 225 | ## [2.1.19] - 2017-08-11 226 | 227 | ## Added 228 | - Danish (da_DK) language files, thanks to [Frederik Rabøl](https://github.com/Xayer); 229 | - Russian (ru) language files, thanks to [exotickg1](https://github.com/exotickg1); 230 | 231 | 232 | ## 2.1.18 - 2017-07-06 233 | 234 | ### Added 235 | - overwritable routes file; 236 | 237 | 238 | ## 2.1.17 - 2017-07-05 239 | 240 | ### Added 241 | - Spanish translation (thanks to [Hugo Aguirre](https://github.com/bul-ikana) and [Cesar Bretana Glez](https://github.com/bretanac93)); 242 | - Portugese translation (thanks to [Toni Almeida](https://github.com/promatik)); 243 | - Dutch translation (thanks to [Jelmer Visser](https://github.com/jelmervisser)); 244 | 245 | ### Fixed 246 | - use local request in UserCrudController instead of Facade; 247 | - use the Users table name as defined in the laravel-permission config file; 248 | - correctly extending CrudController now; 249 | 250 | ## 2.1.16 - 2017-04-21 251 | 252 | ### Removed 253 | - Backpack\PermissionManager no longer loads translations, as Backpack\Base does it for him. 254 | 255 | 256 | ## 2.1.15 - 2017-02-17 257 | 258 | ### Removed 259 | - PHP 5.5 compatibility, as Laravel no longer supports it; 260 | 261 | 262 | ## 2.1.14 - 2017-02-17 263 | 264 | ### Added 265 | - CRUD 3.2 compatibilty; 266 | - updated CONTRIBUTING.md; 267 | 268 | 269 | ## 2.1.13 - 2017-02-13 270 | 271 | ### Added 272 | - greek translation - thanks to [automat64](https://github.com/automat64); 273 | 274 | ### Fixed 275 | - allowed for primary keys other than id; 276 | 277 | 278 | ## 2.1.12 - 2017-02-13 279 | 280 | ### Added 281 | - ajax datatables for users CRUD; 282 | 283 | 284 | ## 2.1.11 - 2017-01-18 285 | 286 | ### Added 287 | - config options to disable the delete functionality on Permissions and Roles; 288 | 289 | 290 | 291 | ## 2.1.10 - 2016-11-28 292 | 293 | ### Added 294 | - you can use a different permission or role model by changing a config value inside the laravel-permission config file; 295 | 296 | 297 | ## 2.1.9 - 2016-10-23 298 | 299 | ### Fixed 300 | - route_prefix support for routes; 301 | 302 | 303 | ## 2.1.8 - 2016-10-20 304 | 305 | ### Fixed 306 | - added translation files, thanks to [Ludio Oliveira](https://github.com/ludioao); 307 | - added route_prefix support, thanks to [reeslo](https://github.com/reeslo); 308 | 309 | 310 | ## 2.1.7 - 2016-09-12 311 | 312 | ### Fixed 313 | - MySQL strict support; 314 | 315 | 316 | ## 2.1.6 - 2016-08-31 317 | 318 | ### Added 319 | - Laravel 5.3 support; 320 | 321 | 322 | ## 2.1.5 - 2016-07-31 323 | 324 | ### Added 325 | - Working bogus unit tests. 326 | 327 | 328 | ## 2.1.3 - 2016-06-30 329 | 330 | ### Added 331 | - Ability to change user model fqcn in config file. 332 | 333 | 334 | ## 2.1.2 - 2016-06-23 335 | 336 | ### Added 337 | - Roles and Permissions columns on UserCrudController list view. 338 | 339 | 340 | ## 2.1.1 - 2016-06-16 341 | 342 | ### Fixed 343 | - When adding users, the password was not saved. 344 | 345 | 346 | ## 2.1.0 - 2016-06-16 347 | 348 | ### Added 349 | - Database migration is now published, for deployment systems like Laravel Forge; 350 | - Config file to disallow create and update for permissions and roles, after you add them; 351 | 352 | ### Fixed 353 | - Moved routes declaration in the ServiceProvider; 354 | - Spatie\Permission\PermissionServiceProvider::class is now registered in the ServiceProvider; 355 | 356 | 357 | ## 2.0.0 - 2016-05-20 358 | 359 | ### Fixed 360 | - Updated controller syntax to use the new Backpack\CRUD API in v2. 361 | 362 | 363 | ## 1.0.4 - 2016-05-18 364 | 365 | ### Fixed 366 | - Installation process. 367 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Having trouble using Backpack? 2 | 3 | No documentation can be 100% complete and Backpack's is no different, sorry for that. There are plenty of people that follow [the StackOverflow tag "backpack-for-laravel"](stackoverflow.com/questions/tagged/backpack-for-laravel) and are glad to help you out. Post your question there and please include: 4 | - (A) what you did 5 | - (B) what you expected to happen 6 | - (C) what happened 7 | - (D) what have you already tried to fix it? 8 | 9 | 10 | # Idea for a new feature? 11 | 12 | **[Open an issue](https://github.com/laravel-backpack/crud) and tell the community you are willing to submit a PR.** We usually end up with better solutions when we talk about it and everybody pitches in with their opinion. Plus, some features might be better presented as a separate package, a tutorial or a code snippet. 13 | 14 | PR Rules: 15 | 16 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 17 | 18 | - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer). It's ok to push non-PSR-2 code, but know that [StyleCI](https://styleci.io/) will convert it after the merge. 19 | 20 | # Discovered a bug? 21 | 22 | **Step 1. [Open an issue](https://github.com/laravel-backpack/crud).** Please include: 23 | - (A) what you did 24 | - (B) what you expected to happen 25 | - (C) what happened 26 | - (D) what have you already tried to fix it? 27 | 28 | **Step 2. Submit a PR.** 29 | If you have a solution for it and want to help, you can submit a Pull Request. Tell us you are willing to do that. It takes a little more time from you, but: 30 | - your fix is guaranteed to be merged a lot faster; 31 | - you'll become one of the Backpack contributors; [welcome to the party! :-)](https://media.giphy.com/media/l0MYt5jPR6QX5pnqM/giphy.gif); 32 | - you'll not just be helping yourself and the maintainers of Backpack, you'd be helping thousants of Backpack developers; 33 | 34 | If you've never submitted a PR before, don't worry, it's not that difficult. Read [this tutoral](https://mattstauffer.co/blog/how-to-contribute-to-an-open-source-github-project-using-your-own-fork) and the rules above. I promise, you'll enjoy sending PRs after a while :-) 35 | 36 | 37 | # Want to help out? 38 | 39 | Thank you, thank you, thank you! You can: 40 | - [add a StackOverflow filter](https://stackexchange.com/filters) to receive emails for backpack-for-laravel questions; 41 | - [install Gitter](https://gitter.im/BackpackForLaravel/Lobby) and help people out in real-time; 42 | - [star Backpack\CRUD on Github](https://github.com/laravel-backpack/crud) so the repository can get more views; 43 | - [purchase a commercial license](https://www.backpackforlaravel.com/commercial-license/form), if you use Backpack to make money; 44 | - [stock up on cheaper commercial licenses](https://www.backpackforlaravel.com/commercial-license/form) before we bump the price to $39; 45 | - ALL OF THE ABOVE. Groundbreaking, I know, right? :-) 46 | 47 | **Happy coding**! 48 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # YUMMY License 2 | 3 | **YoU make Money, I make MoneY.** The license holder is allowed to use the software for free, as long as he doesn't make money by using it. 4 | 5 | Copyright (c) 2015-2017 Cristian Tabacitu 6 | 7 | ## FREE for non-commercial use, PAID for commercial use 8 | 9 | > Permission is hereby granted to any person obtaining a copy of this software 10 | > and associated documentation files (the "Software"), to use the Software. 11 | > This includes the rights to use, copy, modify and/or merge the Sofware 12 | > or copies of the Software, and to permit persons to whom the Software is 13 | > furnished to do so, subject to the following conditions: 14 | > 15 | > **1. Should the Sofware be used for non-commercial purposes (personal use, not-profits, 16 | > testing, education), no financial reward is expected and the above rights are given FREE OF CHARGE.** 17 | > 18 | > **2. Should the Software be used for commercial purposes (the user of this Sofware, 19 | > its employer, employees or clients make money by using this Software), the user is 20 | > required to purchase a "Single Domain License" on [backpackforlaravel.com](https://backpackforlaravel.com), for each 21 | > domain name this sofware will be used on, before its usage in production. 22 | > Failure to do so will constitute as illegal commercial use.** 23 | > 24 | > **3. This license does not include the rights to publish or sublicense 25 | > this Sofware, its copies or any derivations, with or without the purpose of commercial profit. 26 | > For inclusion in commercial packages or SaaS products, an "Unlimited License" is required, which can be purchased on [backpackforlaravel.com](https://backpackforlaravel.com). For inclusion in free open-source packages, express permission is needed from .** 27 | > 28 | > **4. The above copyright notice and this permission notice shall be included in 29 | > all copies or substantial portions of the Software.** 30 | > 31 | > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 32 | > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 33 | > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 34 | > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 35 | > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 36 | > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 37 | > THE SOFTWARE. 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Backpack\PermissionManager 2 | 3 | [![Latest Version on Packagist][ico-version]](link-packagist) 4 | [![Software License][ico-license]](LICENSE.md) 5 | [![Style CI](https://styleci.io/repos/58740020/shield)](https://styleci.io/repos/58740020) 6 | [![Total Downloads][ico-downloads]][link-downloads] 7 | 8 | Admin interface for [spatie/laravel-permission](https://github.com/spatie/laravel-permission). It allows admins to easily add/edit/remove users, roles and permissions, using [Laravel Backpack](https://laravelbackpack.com). 9 | 10 | As opposed to some other packages: 11 | - a user can have multiple roles; 12 | - a user can have extra permissions, in addition to the permissions on the roles he has; 13 | 14 | This package is just a user interface for [spatie/laravel-permission](https://github.com/spatie/laravel-permission). It will install it, and let you use its API in code. Please refer to their README for more information on how to use in code. 15 | 16 | ![Edit a user in Backpack/PermissionManager](https://user-images.githubusercontent.com/1032474/149489620-a3e54d6e-db5f-4241-9afc-dc9451e54b64.gif) 17 | 18 | 19 | 20 | > ### Security updates and breaking changes 21 | > Please **[subscribe to the Backpack Newsletter](http://backpackforlaravel.com/newsletter)** so you can find out about any security updates, breaking changes or major features. We send an email every 1-2 months. 22 | 23 | 24 | ## Install 25 | 26 | 0) This package assumes you've already installed [Backpack for Laravel](https://backpackforlaravel.com). If you haven't, please [install Backpack first](https://backpackforlaravel.com/docs/installation). 27 | 28 | 1) In your terminal: 29 | 30 | ``` bash 31 | composer require backpack/permissionmanager 32 | ``` 33 | 34 | 2) Finish all installation steps for [spatie/laravel-permission](https://github.com/spatie/laravel-permission#installation), which has been pulled as a dependency. Run its migrations. Publish its config files. Most likely it's: 35 | ```shell 36 | php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" --tag="permission-migrations" 37 | php artisan migrate 38 | php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" --tag="permission-config" 39 | // then, add the Spatie\Permission\Traits\HasRoles trait to your User model(s) 40 | ``` 41 | 42 | 3) Publish `backpack\permissionmanager` config file & the migrations: 43 | ```bash 44 | php artisan vendor:publish --provider="Backpack\PermissionManager\PermissionManagerServiceProvider" --tag="config" --tag="migrations" 45 | ``` 46 | > Note: _We recommend you to publish only the config file and migrations, but you may also publish lang and routes._ 47 | 48 | 4) Run the migrations: 49 | ```bash 50 | php artisan migrate 51 | ``` 52 | 53 | 5) The package assumes it's ok to use the default Backpack user model (most likely ```App\Models\User``` to administer Users. Use a different one if you'd like by changing the user model in the ```config/backpack/permissionmanager.php``` file. Any model you're using, make sure it's using the ```CrudTrait``` and ```HasRoles``` traits: 54 | ```php 55 | 75 | 76 | 77 | 78 | 79 | 80 | ``` 81 | 82 | 7) [Optional] If you want to use the ```@can``` handler inside Backpack routes, you can: 83 | 84 | (7.A.) Change Backpack to use the default ```web``` guard instead of its own guard. Inside ```config/backpack/base.php``` change: 85 | ```diff 86 | // The guard that protects the Backpack admin panel. 87 | // If null, the config.auth.defaults.guard value will be used. 88 | - 'guard' => 'backpack', 89 | + 'guard' => null, 90 | ``` 91 | Note: 92 | - when you add new roles and permissions, the guard that gets saved in the database will be "web"; 93 | 94 | OR 95 | 96 | (7.B.) Add a middleware to all your Backpack routes by adding this to your ```config/backpack/base.php``` file: 97 | ```diff 98 | // The classes for the middleware to check if the visitor is an admin 99 | // Can be a single class or an array of classes 100 | 'middleware_class' => [ 101 | App\Http\Middleware\CheckIfAdmin::class, 102 | \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, 103 | + Backpack\CRUD\app\Http\Middleware\UseBackpackAuthGuardInsteadOfDefaultAuthGuard::class, 104 | ], 105 | ``` 106 | 107 | Why? `spatie/laravel-permission` uses the ```Auth``` facade for determining permissions with ```@can```. The ```Auth``` facade uses the default guard defined in ```config/auth.php```, NOT our backpack guard. 108 | 109 | Please note: 110 | - this will make ```auth()``` return the exact same thing as ```backpack_auth()``` on Backpack routes; 111 | - you only need this if you want to use ```@can```; you can just as well use ```@if(backpack_user()->can('read'))```, which does the exact same thing, but works 100% of the time; 112 | - when you add new roles and permissions, the guard that gets saved in the database will be "backpack"; 113 | 114 | 115 | 8) [Optional] Disallow create/update on your roles or permissions after you define them, using the config file in **config/backpack/permissionmanager.php**. Please note permissions and roles are referenced in code using their name. If you let your admins edit these strings and they do, your permission and role checks will stop working. 116 | 117 | 118 | ## Customize UserCrudController 119 | 120 | If you would like to add more fields to the default user controller provided by this package, you can bind your own controller to overwrite the one provided in this package: 121 | 122 | ```php 123 | // in some ServiceProvider, AppServiceProvider for example 124 | 125 | $this->app->bind( 126 | \Backpack\PermissionManager\app\Http\Controllers\UserCrudController::class, //this is package controller 127 | \App\Http\Controllers\Admin\UserCrudController::class //this should be your own controller 128 | ); 129 | 130 | // this tells Laravel that when UserCrudController is requested, your own UserCrudController should be served. 131 | ``` 132 | 133 | 134 | ## API Usage 135 | 136 | Because the package requires [spatie/laravel-permission](https://github.com/spatie/laravel-permission), the API will be the same. Please refer to their README file for a complete API. Here's a summary though: 137 | 138 | 139 | ### Using permissions 140 | 141 | A permission can be given to a user: 142 | 143 | ``` bash 144 | backpack_user()->givePermissionTo('edit articles'); 145 | ``` 146 | A permission can be revoked from a user: 147 | ``` bash 148 | backpack_user()->revokePermissionTo('edit articles'); 149 | ``` 150 | You can test if a user has a permission: 151 | ``` bash 152 | backpack_user()->hasPermissionTo('edit articles'); 153 | ``` 154 | 155 | Saved permissions will be registered with the Illuminate\Auth\Access\Gate-class. So you can test if a user has a permission with Laravel's default can-function. 156 | ``` bash 157 | backpack_user()->can('edit articles'); 158 | ``` 159 | ### Using roles and permissions 160 | 161 | A role can be assigned to a user: 162 | ``` bash 163 | backpack_user()->assignRole('writer'); 164 | ``` 165 | A role can be removed from a user: 166 | ``` bash 167 | backpack_user()->removeRole('writer'); 168 | ``` 169 | You can determine if a user has a certain role: 170 | ``` bash 171 | backpack_user()->hasRole('writer'); 172 | ``` 173 | You can also determine if a user has any of a given list of roles: 174 | ``` bash 175 | backpack_user()->hasAnyRole(Role::all()); 176 | ``` 177 | You can also determine if a user has all of a given list of roles: 178 | ``` bash 179 | backpack_user()->hasAllRoles(Role::all()); 180 | ``` 181 | The assignRole, hasRole, hasAnyRole, hasAllRoles and removeRole-functions can accept a string, an array, a Role-object or an \Illuminate\Support\Collection-object. 182 | 183 | A permission can be given to a role: 184 | ``` bash 185 | $role->givePermissionTo('edit articles'); 186 | ``` 187 | You can determine if a role has a certain permission: 188 | ``` bash 189 | $role->hasPermissionTo('edit articles'); 190 | ``` 191 | A permission can be revoked from a role: 192 | ``` bash 193 | $role->revokePermissionTo('edit articles'); 194 | ``` 195 | The givePermissionTo and revokePermissionTo-functions can accept a string or a Permission-object. 196 | 197 | Saved permission and roles are also registered with the Illuminate\Auth\Access\Gate-class. 198 | 199 | ``` bash 200 | backpack_user()->can('edit articles'); 201 | ``` 202 | ### Using blade directives 203 | 204 | This package also adds Blade directives to verify whether the currently logged in user has all or any of a given list of roles. 205 | ``` bash 206 | @role('writer') 207 | I\'m a writer! 208 | @else 209 | I\'m not a writer... 210 | @endrole 211 | @hasrole('writer') 212 | I\'m a writer! 213 | @else 214 | I\'m not a writer... 215 | @endhasrole 216 | @hasanyrole(Role::all()) 217 | I have one or more of these roles! 218 | @else 219 | I have none of these roles... 220 | @endhasanyrole 221 | @hasallroles(Role::all()) 222 | I have all of these roles! 223 | @else 224 | I don\'t have all of these roles 225 | @endhasallroles 226 | ``` 227 | 228 | You can use Laravel's native @can directive to check if a user has a certain permission. 229 | 230 | ## Use permissions in CRUD controllers 231 | 232 | CRUD controllers have methods to [dynamically allow or deny access](https://backpackforlaravel.com/docs/6.x/crud-api#access) to operations. The ```$this->crud->allowAccess()``` and ```$this->crud->denyAccess()``` methods control both: 233 | - the form's navigation buttons display like Add, Edit, Delete and 234 | - the security access guards, returning a 403 forbidden error when no permission. 235 | 236 | In most cases, you should use `access` and `permission` separately. But if you want to link them together, so a "permission" gives "access", here is how you can do that too. Reminder: permissions can be assigned to a user either directly or through a role. 237 | 238 | 1) Define a ```CrudPermissionTrait``` 239 | ``` php 240 | namespace App\Traits; 241 | 242 | use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD; 243 | 244 | /** 245 | * CrudPermissionTrait: use Permissions to configure Backpack 246 | */ 247 | trait CrudPermissionTrait 248 | { 249 | // the operations defined for CRUD controller 250 | public array $operations = ['list', 'show', 'create', 'update', 'delete']; 251 | 252 | 253 | /** 254 | * set CRUD access using spatie Permissions defined for logged in user 255 | * 256 | * @return void 257 | */ 258 | public function setAccessUsingPermissions() 259 | { 260 | // default 261 | $this->crud->denyAccess($this->operations); 262 | 263 | // get context 264 | $table = CRUD::getModel()->getTable(); 265 | $user = request()->user(); 266 | 267 | // double check if no authenticated user 268 | if (!$user) { 269 | return; // allow nothing 270 | } 271 | 272 | // enable operations depending on permission 273 | foreach ([ 274 | // permission level => [crud operations] 275 | 'see' => ['list', 'show'], // e.g. permission 'users.see' allows to display users 276 | 'edit' => ['list', 'show', 'create', 'update', 'delete'], // e.g. 'users.edit' permission allows all operations 277 | ] as $level => $operations) { 278 | if ($user->can("$table.$level")) { 279 | $this->crud->allowAccess($operations); 280 | } 281 | } 282 | } 283 | } 284 | ``` 285 | 286 | 2) Use the above ```CrudPermissionTrait``` trait in any ````CrudController````, ```UserCrudController``` in this example. 287 | 288 | ```php 289 | namespace App\Http\Controllers\Admin; 290 | 291 | use Backpack\PermissionManager\app\Http\Controllers\UserCrudController as BackpackUserCrudController; 292 | 293 | class UserCrudController extends BackpackUserCrudController 294 | { 295 | use \App\Traits\CrudPermissionTrait; 296 | 297 | public function setup() 298 | { 299 | parent::setup(); 300 | $this->setAccessUsingPermissions(); 301 | } 302 | } 303 | ``` 304 | 305 | Now make sure the route uses the right controller: 306 | 307 | (3.A) by binding the package controller to your controller as explained in [Customize UserCrudController](https://github.com/Laravel-Backpack/PermissionManager#customize-usercrudcontroller) 308 | 309 | ```php 310 | $this->app->bind( 311 | \Backpack\PermissionManager\app\Http\Controllers\UserCrudController::class, // package controller 312 | \App\Http\Controllers\Admin\UserCrudController::class // the controller using CrudPermissionTrait 313 | ); 314 | ``` 315 | 316 | OR 317 | 318 | (3.B) by defining the routes in your own ```routes/backpack/permissionmanager.php``` file as explained in [Overwriting fuctionality](https://github.com/Laravel-Backpack/PermissionManager#overwriting-functionality) 319 | ```php 320 | Route::group([ 321 | 'namespace' => 'App\Http\Controllers\Admin', // the new namespace 322 | 'prefix' => config('backpack.base.route_prefix', 'admin'), 323 | 'middleware' => ['web', backpack_middleware()], 324 | ], function () { 325 | // the adapted controllers 326 | Route::crud('user', 'UserCrudController'); 327 | // Route::crud('role', 'RoleCrudController'); 328 | }); 329 | Route::group([ 330 | 'namespace' => '\Backpack\PermissionManager\app\Http\Controllers', // the original namespace 331 | 'prefix' => config('backpack.base.route_prefix', 'admin'), 332 | 'middleware' => ['web', backpack_middleware()], 333 | ], function () { 334 | // to original controllers 335 | // not modified yet in this example 336 | Route::crud('permission', 'PermissionCrudController'); 337 | Route::crud('role', 'RoleCrudController'); 338 | }); 339 | ``` 340 | 341 | 342 | You may wish to use a ```PermissionSeeder``` to automatically populate the ```permission``` table with permissions corresponding to your code. Here is an example: 343 | 344 | ```php 345 | namespace Database\Seeders; 346 | 347 | use App\Models\User; 348 | use Illuminate\Database\Seeder; 349 | use Backpack\PermissionManager\app\Models\Permission; 350 | use Backpack\PermissionManager\app\Models\Role; 351 | 352 | class PermissionSeeder extends Seeder 353 | { 354 | /** 355 | * Run the database Permission seed. 356 | 357 | * Permissions are fixed in code and are seeded here. 358 | * use 'php artisan db:seed --class=PermissionSeeder --force' in production 359 | * 360 | * @return void 361 | */ 362 | public function run() 363 | { 364 | // create permission for each combination of table.level 365 | collect([ // tables 366 | 'users', 367 | 'roles', 368 | ]) 369 | ->crossJoin([ // levels 370 | 'see', 371 | 'edit', 372 | ]) 373 | ->each( 374 | fn (array $item) => Permission::firstOrCreate([ 375 | 'name' => implode('.', $item), 376 | ]) 377 | ->save() 378 | ) 379 | // 380 | ; 381 | User::first() 382 | ->givePermissionTo(['users.edit']); 383 | } 384 | } 385 | ``` 386 | Use ```php artisan db:seed --class=PermissionSeeder --force``` in production 387 | 388 | ## Upgrade from 3.x to 4.x 389 | 390 | To upgrade from PermissionManager 3.x to 4.x: 391 | - upgrade to spatie/laravel-permission 2.28.2+ - do take note that the DB has changed, and they don't provide a track of the changes; 392 | - require ```backpack/permissionmanager``` version ```4.0.*``` in your ```composer.json``` file; 393 | - delete your old ```config/backpack/permissionmanager.php``` file; 394 | - follow the installation steps above; 395 | 396 | If you are upgrading to a Laravel 8 instalation, please note that User Model may have moved from ```App\User::class``` to ```App\Models\User::class```, check if your config is compliant with that change ```config/backpack/permissionmanager.php```. 397 | 398 | ## Change log 399 | 400 | Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. 401 | 402 | ## Overwriting functionality 403 | 404 | If you need to modify how this works in a project: 405 | - create a ```routes/backpack/permissionmanager.php``` file; the package will see that, and load _your_ routes file, instead of the one in the package; 406 | - create controllers/models that extend the ones in the package, and use those in your new routes file; 407 | - modify anything you'd like in the new controllers/models; 408 | 409 | When creating your own controllers, seeders, make sure you use the ```BackpackUser``` model, instead of the ```User``` model in your app. The easiest would be to use ```config('backpack.base.user_model_fqn')``` which pulls in the User model fully qualified namespace, as defined in your ```config/backpack/base.php```. You might need to instantiate it using ```$model = config('backpack.base.user_model_fqn'); $model = new $model;``` in order to do things like ```$model->where(...)```. 410 | 411 | ## Contributing 412 | 413 | Please see [CONTRIBUTING](CONTRIBUTING.md) for details. 414 | 415 | ## Security 416 | 417 | If you discover any security related issues, please email tabacitu@backpackforlaravel.com instead of using the issue tracker. 418 | 419 | Please **[subscribe to the Backpack Newsletter](http://backpackforlaravel.com/newsletter)** so you can find out about any security updates, breaking changes or major features. We send an email every 1-2 months. 420 | 421 | ## Credits 422 | 423 | - [Marius Constantin][link-author2] - Lead Developer 424 | - [Cristian Tabacitu][link-author] - Maintainer 425 | - [All Contributors][link-contributors] 426 | 427 | ## License 428 | 429 | Backpack is free for non-commercial use and 49 EUR/project for commercial use. Please see [License File](LICENSE.md) and [backpackforlaravel.com](https://backpackforlaravel.com/#pricing) for more information. 430 | 431 | ## Hire us 432 | 433 | We've spend more than 50.000 hours creating, polishing and maintaining administration panels on Laravel. We've developed e-Commerce, e-Learning, ERPs, social networks, payment gateways and much more. We've worked on admin panels _so much_, that we've created one of the most popular software in its niche - just from making public what was repetitive in our projects. 434 | 435 | If you are looking for a developer/team to help you build an admin panel on Laravel, look no further. You'll have a difficult time finding someone with more experience & enthusiasm for this. This is _what we do_. [Contact us](https://backpackforlaravel.com/need-freelancer-or-development-team). Let's see if we can work together. 436 | 437 | 438 | [ico-version]: https://img.shields.io/packagist/v/backpack/permissionmanager.svg?style=flat-square 439 | [ico-license]: https://img.shields.io/badge/license-dual-blue?style=flat-square 440 | [ico-travis]: https://img.shields.io/travis/laravel-backpack/permissionmanager/master.svg?style=flat-square 441 | [ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/laravel-backpack/permissionmanager.svg?style=flat-square 442 | [ico-code-quality]: https://img.shields.io/scrutinizer/g/laravel-backpack/permissionmanager.svg?style=flat-square 443 | [ico-downloads]: https://img.shields.io/packagist/dt/backpack/permissionmanager.svg?style=flat-square 444 | 445 | [link-packagist]: https://packagist.org/packages/backpack/permissionmanager 446 | [link-travis]: https://travis-ci.org/laravel-backpack/permissionmanager 447 | [link-scrutinizer]: https://scrutinizer-ci.com/g/laravel-backpack/permissionmanager/code-structure 448 | [link-code-quality]: https://scrutinizer-ci.com/g/laravel-backpack/permissionmanager 449 | [link-downloads]: https://packagist.org/packages/backpack/permissionmanager 450 | [link-author]: http://tabacitu.ro 451 | [link-author2]: http://updivision.com 452 | [link-contributors]: ../../contributors 453 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "backpack/permissionmanager", 3 | "description": "Users and permissions management interface for Laravel 5 using Backpack CRUD.", 4 | "keywords": [ 5 | "tabacitu", 6 | "laravel backpack", 7 | "backpack permission", 8 | "backpack roles", 9 | "backpack user management", 10 | "updivision", 11 | "backpack", 12 | "manage permission", 13 | "manage roles", 14 | "manage users", 15 | "users roles admin" 16 | ], 17 | "homepage": "https://github.com/laravel-backpack/permissionmanager", 18 | "license": "proprietary", 19 | "authors": [ 20 | { 21 | "name": "Marius Constantin", 22 | "email": "marius@updivision.com", 23 | "homepage": "http://www.updivision.com", 24 | "role": "Lead Developer" 25 | }, 26 | { 27 | "name": "Cristian Tabacitu", 28 | "email": "tabacitu@backpackforlaravel.com", 29 | "homepage": "https://backpackforlaravel.com", 30 | "role": "Chief Architect" 31 | } 32 | ], 33 | "minimum-stability": "dev", 34 | "prefer-stable": true, 35 | "require": { 36 | "spatie/laravel-permission": "^6.4||^5.0||^4.0||^3.0", 37 | "backpack/crud": "^6.0" 38 | }, 39 | "autoload": { 40 | "psr-4": { 41 | "Backpack\\PermissionManager\\": "src" 42 | } 43 | }, 44 | "extra": { 45 | "laravel": { 46 | "providers": [ 47 | "Backpack\\PermissionManager\\PermissionManagerServiceProvider" 48 | ] 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/PermissionManagerServiceProvider.php: -------------------------------------------------------------------------------- 1 | setupRoutes($this->app->router); 34 | 35 | // use the vendor configuration file as fallback 36 | $this->mergeConfigFrom( 37 | __DIR__.'/config/backpack/permissionmanager.php', 38 | 'backpack.permissionmanager' 39 | ); 40 | 41 | // publish config file 42 | $this->publishes([__DIR__.'/config' => config_path()], 'config'); 43 | 44 | // publish translation files 45 | $this->publishes([__DIR__.'/resources/lang' => app()->langPath().'/vendor/backpack'], 'lang'); 46 | 47 | // publish route file 48 | $this->publishes([__DIR__.$this->routeFilePath => base_path($this->routeFilePath)], 'routes'); 49 | 50 | // publish migration from Backpack 4.0 to Backpack 4.1 51 | $this->publishes([__DIR__.'/database/migrations' => database_path('migrations')], 'migrations'); 52 | } 53 | 54 | /** 55 | * Define the routes for the application. 56 | * 57 | * @param \Illuminate\Routing\Router $router 58 | * 59 | * @return void 60 | */ 61 | public function setupRoutes(Router $router) 62 | { 63 | // by default, use the routes file provided in vendor 64 | $routeFilePathInUse = __DIR__.$this->routeFilePath; 65 | 66 | // but if there's a file with the same name in routes/backpack, use that one 67 | if (file_exists(base_path().$this->routeFilePath)) { 68 | $routeFilePathInUse = base_path().$this->routeFilePath; 69 | } 70 | 71 | $this->loadRoutesFrom($routeFilePathInUse); 72 | } 73 | 74 | /** 75 | * Register any package services. 76 | * 77 | * @return void 78 | */ 79 | public function register() 80 | { 81 | $this->app->register(PermissionServiceProvider::class); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/app/Http/Controllers/PermissionCrudController.php: -------------------------------------------------------------------------------- 1 | role_model = $role_model = config('backpack.permissionmanager.models.role'); 25 | $this->permission_model = $permission_model = config('backpack.permissionmanager.models.permission'); 26 | 27 | $this->crud->setModel($permission_model); 28 | $this->crud->setEntityNameStrings(trans('backpack::permissionmanager.permission_singular'), trans('backpack::permissionmanager.permission_plural')); 29 | $this->crud->setRoute(backpack_url('permission')); 30 | 31 | // deny access according to configuration file 32 | if (config('backpack.permissionmanager.allow_permission_create') == false) { 33 | $this->crud->denyAccess('create'); 34 | } 35 | if (config('backpack.permissionmanager.allow_permission_update') == false) { 36 | $this->crud->denyAccess('update'); 37 | } 38 | if (config('backpack.permissionmanager.allow_permission_delete') == false) { 39 | $this->crud->denyAccess('delete'); 40 | } 41 | } 42 | 43 | public function setupListOperation() 44 | { 45 | $this->crud->addColumn([ 46 | 'name' => 'name', 47 | 'label' => trans('backpack::permissionmanager.name'), 48 | 'type' => 'text', 49 | ]); 50 | 51 | if (config('backpack.permissionmanager.multiple_guards')) { 52 | $this->crud->addColumn([ 53 | 'name' => 'guard_name', 54 | 'label' => trans('backpack::permissionmanager.guard_type'), 55 | 'type' => 'text', 56 | ]); 57 | } 58 | } 59 | 60 | public function setupCreateOperation() 61 | { 62 | $this->addFields(); 63 | $this->crud->setValidation(StoreRequest::class); 64 | 65 | //otherwise, changes won't have effect 66 | app()->make(PermissionRegistrar::class)->forgetCachedPermissions(); 67 | } 68 | 69 | public function setupUpdateOperation() 70 | { 71 | $this->addFields(); 72 | $this->crud->setValidation(UpdateRequest::class); 73 | 74 | //otherwise, changes won't have effect 75 | app()->make(PermissionRegistrar::class)->forgetCachedPermissions(); 76 | } 77 | 78 | private function addFields() 79 | { 80 | $this->crud->addField([ 81 | 'name' => 'name', 82 | 'label' => trans('backpack::permissionmanager.name'), 83 | 'type' => 'text', 84 | ]); 85 | 86 | if (config('backpack.permissionmanager.multiple_guards')) { 87 | $this->crud->addField([ 88 | 'name' => 'guard_name', 89 | 'label' => trans('backpack::permissionmanager.guard_type'), 90 | 'type' => 'select_from_array', 91 | 'options' => $this->getGuardTypes(), 92 | ]); 93 | } 94 | } 95 | 96 | /* 97 | * Get an array list of all available guard types 98 | * that have been defined in app/config/auth.php 99 | * 100 | * @return array 101 | **/ 102 | private function getGuardTypes() 103 | { 104 | $guards = config('auth.guards'); 105 | 106 | $returnable = []; 107 | foreach ($guards as $key => $details) { 108 | $returnable[$key] = $key; 109 | } 110 | 111 | return $returnable; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/app/Http/Controllers/RoleCrudController.php: -------------------------------------------------------------------------------- 1 | role_model = $role_model = config('backpack.permissionmanager.models.role'); 25 | $this->permission_model = $permission_model = config('backpack.permissionmanager.models.permission'); 26 | 27 | $this->crud->setModel($role_model); 28 | $this->crud->setEntityNameStrings(trans('backpack::permissionmanager.role'), trans('backpack::permissionmanager.roles')); 29 | $this->crud->setRoute(backpack_url('role')); 30 | 31 | // deny access according to configuration file 32 | if (config('backpack.permissionmanager.allow_role_create') == false) { 33 | $this->crud->denyAccess('create'); 34 | } 35 | if (config('backpack.permissionmanager.allow_role_update') == false) { 36 | $this->crud->denyAccess('update'); 37 | } 38 | if (config('backpack.permissionmanager.allow_role_delete') == false) { 39 | $this->crud->denyAccess('delete'); 40 | } 41 | } 42 | 43 | public function setupListOperation() 44 | { 45 | /** 46 | * Show a column for the name of the role. 47 | */ 48 | $this->crud->addColumn([ 49 | 'name' => 'name', 50 | 'label' => trans('backpack::permissionmanager.name'), 51 | 'type' => 'text', 52 | ]); 53 | 54 | /** 55 | * Show a column with the number of users that have that particular role. 56 | * 57 | * Note: To account for the fact that there can be thousands or millions 58 | * of users for a role, we did not use the `relationship_count` column, 59 | * but instead opted to append a fake `user_count` column to 60 | * the result, using Laravel's `withCount()` method. 61 | * That way, no users are loaded. 62 | */ 63 | $this->crud->query->withCount('users'); 64 | $this->crud->addColumn([ 65 | 'label' => trans('backpack::permissionmanager.users'), 66 | 'type' => 'text', 67 | 'name' => 'users_count', 68 | 'wrapper' => [ 69 | 'href' => function ($crud, $column, $entry, $related_key) { 70 | return backpack_url('user?role='.$entry->getKey()); 71 | }, 72 | ], 73 | 'suffix' => ' '.strtolower(trans('backpack::permissionmanager.users')), 74 | ]); 75 | 76 | /** 77 | * In case multiple guards are used, show a column for the guard. 78 | */ 79 | if (config('backpack.permissionmanager.multiple_guards')) { 80 | $this->crud->addColumn([ 81 | 'name' => 'guard_name', 82 | 'label' => trans('backpack::permissionmanager.guard_type'), 83 | 'type' => 'text', 84 | ]); 85 | } 86 | 87 | /** 88 | * Show the exact permissions that role has. 89 | */ 90 | $this->crud->addColumn([ 91 | // n-n relationship (with pivot table) 92 | 'label' => mb_ucfirst(trans('backpack::permissionmanager.permission_plural')), 93 | 'type' => 'select_multiple', 94 | 'name' => 'permissions', // the method that defines the relationship in your Model 95 | 'entity' => 'permissions', // the method that defines the relationship in your Model 96 | 'attribute' => 'name', // foreign key attribute that is shown to user 97 | 'model' => $this->permission_model, // foreign key model 98 | 'pivot' => true, // on create&update, do you need to add/delete pivot table entries? 99 | ]); 100 | } 101 | 102 | public function setupCreateOperation() 103 | { 104 | $this->addFields(); 105 | $this->crud->setValidation(StoreRequest::class); 106 | 107 | //otherwise, changes won't have effect 108 | app()->make(PermissionRegistrar::class)->forgetCachedPermissions(); 109 | } 110 | 111 | public function setupUpdateOperation() 112 | { 113 | $this->addFields(); 114 | $this->crud->setValidation(UpdateRequest::class); 115 | 116 | //otherwise, changes won't have effect 117 | app()->make(PermissionRegistrar::class)->forgetCachedPermissions(); 118 | } 119 | 120 | private function addFields() 121 | { 122 | $this->crud->addField([ 123 | 'name' => 'name', 124 | 'label' => trans('backpack::permissionmanager.name'), 125 | 'type' => 'text', 126 | ]); 127 | 128 | if (config('backpack.permissionmanager.multiple_guards')) { 129 | $this->crud->addField([ 130 | 'name' => 'guard_name', 131 | 'label' => trans('backpack::permissionmanager.guard_type'), 132 | 'type' => 'select_from_array', 133 | 'options' => $this->getGuardTypes(), 134 | ]); 135 | } 136 | 137 | $this->crud->addField([ 138 | 'label' => mb_ucfirst(trans('backpack::permissionmanager.permission_plural')), 139 | 'type' => 'checklist', 140 | 'name' => 'permissions', 141 | 'entity' => 'permissions', 142 | 'attribute' => 'name', 143 | 'model' => $this->permission_model, 144 | 'pivot' => true, 145 | ]); 146 | } 147 | 148 | /* 149 | * Get an array list of all available guard types 150 | * that have been defined in app/config/auth.php 151 | * 152 | * @return array 153 | **/ 154 | private function getGuardTypes() 155 | { 156 | $guards = config('auth.guards'); 157 | 158 | $returnable = []; 159 | foreach ($guards as $key => $details) { 160 | $returnable[$key] = $key; 161 | } 162 | 163 | return $returnable; 164 | } 165 | } 166 | -------------------------------------------------------------------------------- /src/app/Http/Controllers/UserCrudController.php: -------------------------------------------------------------------------------- 1 | crud->setModel(config('backpack.permissionmanager.models.user')); 21 | $this->crud->setEntityNameStrings(trans('backpack::permissionmanager.user'), trans('backpack::permissionmanager.users')); 22 | $this->crud->setRoute(backpack_url('user')); 23 | } 24 | 25 | public function setupListOperation() 26 | { 27 | $this->crud->addColumns([ 28 | [ 29 | 'name' => 'name', 30 | 'label' => trans('backpack::permissionmanager.name'), 31 | 'type' => 'text', 32 | ], 33 | [ 34 | 'name' => 'email', 35 | 'label' => trans('backpack::permissionmanager.email'), 36 | 'type' => 'email', 37 | ], 38 | [ // n-n relationship (with pivot table) 39 | 'label' => trans('backpack::permissionmanager.roles'), // Table column heading 40 | 'type' => 'select_multiple', 41 | 'name' => 'roles', // the method that defines the relationship in your Model 42 | 'entity' => 'roles', // the method that defines the relationship in your Model 43 | 'attribute' => 'name', // foreign key attribute that is shown to user 44 | 'model' => config('permission.models.role'), // foreign key model 45 | ], 46 | [ // n-n relationship (with pivot table) 47 | 'label' => trans('backpack::permissionmanager.extra_permissions'), // Table column heading 48 | 'type' => 'select_multiple', 49 | 'name' => 'permissions', // the method that defines the relationship in your Model 50 | 'entity' => 'permissions', // the method that defines the relationship in your Model 51 | 'attribute' => 'name', // foreign key attribute that is shown to user 52 | 'model' => config('permission.models.permission'), // foreign key model 53 | ], 54 | ]); 55 | 56 | if (backpack_pro()) { 57 | // Role Filter 58 | $this->crud->addFilter( 59 | [ 60 | 'name' => 'role', 61 | 'type' => 'dropdown', 62 | 'label' => trans('backpack::permissionmanager.role'), 63 | ], 64 | config('permission.models.role')::all()->pluck('name', 'id')->toArray(), 65 | function ($value) { // if the filter is active 66 | $this->crud->addClause('whereHas', 'roles', function ($query) use ($value) { 67 | $query->where('role_id', '=', $value); 68 | }); 69 | } 70 | ); 71 | 72 | // Extra Permission Filter 73 | $this->crud->addFilter( 74 | [ 75 | 'name' => 'permissions', 76 | 'type' => 'select2', 77 | 'label' => trans('backpack::permissionmanager.extra_permissions'), 78 | ], 79 | config('permission.models.permission')::all()->pluck('name', 'id')->toArray(), 80 | function ($value) { // if the filter is active 81 | $this->crud->addClause('whereHas', 'permissions', function ($query) use ($value) { 82 | $query->where('permission_id', '=', $value); 83 | }); 84 | } 85 | ); 86 | } 87 | } 88 | 89 | public function setupCreateOperation() 90 | { 91 | $this->addUserFields(); 92 | $this->crud->setValidation(StoreRequest::class); 93 | } 94 | 95 | public function setupUpdateOperation() 96 | { 97 | $this->addUserFields(); 98 | $this->crud->setValidation(UpdateRequest::class); 99 | } 100 | 101 | public function setupShowOperation() 102 | { 103 | // automatically add the columns 104 | $this->crud->column('name'); 105 | $this->crud->column('email'); 106 | $this->crud->column([ 107 | // two interconnected entities 108 | 'label' => trans('backpack::permissionmanager.user_role_permission'), 109 | 'field_unique_name' => 'user_role_permission', 110 | 'type' => 'checklist_dependency', 111 | 'name' => 'roles_permissions', 112 | 'subfields' => [ 113 | 'primary' => [ 114 | 'label' => trans('backpack::permissionmanager.role'), 115 | 'name' => 'roles', // the method that defines the relationship in your Model 116 | 'entity' => 'roles', // the method that defines the relationship in your Model 117 | 'entity_secondary' => 'permissions', // the method that defines the relationship in your Model 118 | 'attribute' => 'name', // foreign key attribute that is shown to user 119 | 'model' => config('permission.models.role'), // foreign key model 120 | ], 121 | 'secondary' => [ 122 | 'label' => mb_ucfirst(trans('backpack::permissionmanager.permission_singular')), 123 | 'name' => 'permissions', // the method that defines the relationship in your Model 124 | 'entity' => 'permissions', // the method that defines the relationship in your Model 125 | 'entity_primary' => 'roles', // the method that defines the relationship in your Model 126 | 'attribute' => 'name', // foreign key attribute that is shown to user 127 | 'model' => config('permission.models.permission'), // foreign key model, 128 | ], 129 | ], 130 | ]); 131 | $this->crud->column('created_at'); 132 | $this->crud->column('updated_at'); 133 | } 134 | 135 | /** 136 | * Store a newly created resource in the database. 137 | * 138 | * @return \Illuminate\Http\RedirectResponse 139 | */ 140 | public function store() 141 | { 142 | $this->crud->setRequest($this->crud->validateRequest()); 143 | $this->crud->setRequest($this->handlePasswordInput($this->crud->getRequest())); 144 | $this->crud->unsetValidation(); // validation has already been run 145 | 146 | return $this->traitStore(); 147 | } 148 | 149 | /** 150 | * Update the specified resource in the database. 151 | * 152 | * @return \Illuminate\Http\RedirectResponse 153 | */ 154 | public function update() 155 | { 156 | $this->crud->setRequest($this->crud->validateRequest()); 157 | $this->crud->setRequest($this->handlePasswordInput($this->crud->getRequest())); 158 | $this->crud->unsetValidation(); // validation has already been run 159 | 160 | return $this->traitUpdate(); 161 | } 162 | 163 | /** 164 | * Handle password input fields. 165 | */ 166 | protected function handlePasswordInput($request) 167 | { 168 | // Remove fields not present on the user. 169 | $request->request->remove('password_confirmation'); 170 | $request->request->remove('roles_show'); 171 | $request->request->remove('permissions_show'); 172 | 173 | // Encrypt password if specified. 174 | if ($request->input('password')) { 175 | $request->request->set('password', Hash::make($request->input('password'))); 176 | } else { 177 | $request->request->remove('password'); 178 | } 179 | 180 | return $request; 181 | } 182 | 183 | protected function addUserFields() 184 | { 185 | $this->crud->addFields([ 186 | [ 187 | 'name' => 'name', 188 | 'label' => trans('backpack::permissionmanager.name'), 189 | 'type' => 'text', 190 | ], 191 | [ 192 | 'name' => 'email', 193 | 'label' => trans('backpack::permissionmanager.email'), 194 | 'type' => 'email', 195 | ], 196 | [ 197 | 'name' => 'password', 198 | 'label' => trans('backpack::permissionmanager.password'), 199 | 'type' => 'password', 200 | ], 201 | [ 202 | 'name' => 'password_confirmation', 203 | 'label' => trans('backpack::permissionmanager.password_confirmation'), 204 | 'type' => 'password', 205 | ], 206 | [ 207 | // two interconnected entities 208 | 'label' => trans('backpack::permissionmanager.user_role_permission'), 209 | 'field_unique_name' => 'user_role_permission', 210 | 'type' => 'checklist_dependency', 211 | 'name' => 'roles,permissions', 212 | 'subfields' => [ 213 | 'primary' => [ 214 | 'label' => trans('backpack::permissionmanager.roles'), 215 | 'name' => 'roles', // the method that defines the relationship in your Model 216 | 'entity' => 'roles', // the method that defines the relationship in your Model 217 | 'entity_secondary' => 'permissions', // the method that defines the relationship in your Model 218 | 'attribute' => 'name', // foreign key attribute that is shown to user 219 | 'model' => config('permission.models.role'), // foreign key model 220 | 'pivot' => true, // on create&update, do you need to add/delete pivot table entries?] 221 | 'number_columns' => 3, //can be 1,2,3,4,6 222 | ], 223 | 'secondary' => [ 224 | 'label' => mb_ucfirst(trans('backpack::permissionmanager.permission_plural')), 225 | 'name' => 'permissions', // the method that defines the relationship in your Model 226 | 'entity' => 'permissions', // the method that defines the relationship in your Model 227 | 'entity_primary' => 'roles', // the method that defines the relationship in your Model 228 | 'attribute' => 'name', // foreign key attribute that is shown to user 229 | 'model' => config('permission.models.permission'), // foreign key model 230 | 'pivot' => true, // on create&update, do you need to add/delete pivot table entries?] 231 | 'number_columns' => 3, //can be 1,2,3,4,6 232 | ], 233 | ], 234 | ], 235 | ]); 236 | } 237 | } 238 | -------------------------------------------------------------------------------- /src/app/Http/Requests/PermissionStoreCrudRequest.php: -------------------------------------------------------------------------------- 1 | check(); 18 | } 19 | 20 | /** 21 | * Get the validation rules that apply to the request. 22 | * 23 | * @return array 24 | */ 25 | public function rules() 26 | { 27 | $rules = [ 28 | 'name' => 'required|string|max:255|unique:'.config('permission.table_names.permissions', 'permissions').',name', 29 | ]; 30 | 31 | return $rules; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/app/Http/Requests/PermissionUpdateCrudRequest.php: -------------------------------------------------------------------------------- 1 | check(); 18 | } 19 | 20 | /** 21 | * Get the validation rules that apply to the request. 22 | * 23 | * @return array 24 | */ 25 | public function rules() 26 | { 27 | $rules = [ 28 | 'name' => 'required|string|max:255', 29 | ]; 30 | 31 | return $rules; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/app/Http/Requests/RoleStoreCrudRequest.php: -------------------------------------------------------------------------------- 1 | check(); 18 | } 19 | 20 | /** 21 | * Get the validation rules that apply to the request. 22 | * 23 | * @return array 24 | */ 25 | public function rules() 26 | { 27 | $rules = [ 28 | 'name' => 'required|string|max:255|unique:'.config('permission.table_names.roles', 'roles').',name', 29 | ]; 30 | 31 | return $rules; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/app/Http/Requests/RoleUpdateCrudRequest.php: -------------------------------------------------------------------------------- 1 | check(); 18 | } 19 | 20 | /** 21 | * Get the validation rules that apply to the request. 22 | * 23 | * @return array 24 | */ 25 | public function rules() 26 | { 27 | $rules = [ 28 | 'name' => 'required|string|max:255', 29 | ]; 30 | 31 | return $rules; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/app/Http/Requests/UserStoreCrudRequest.php: -------------------------------------------------------------------------------- 1 | check(); 18 | } 19 | 20 | /** 21 | * Get the validation rules that apply to the request. 22 | * 23 | * @return array 24 | */ 25 | public function rules() 26 | { 27 | return [ 28 | 'email' => 'required|unique:'.config('backpack.permissionmanager.models.user', 'users').',email', 29 | 'name' => 'required', 30 | 'password' => 'required|confirmed', 31 | ]; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/app/Http/Requests/UserUpdateCrudRequest.php: -------------------------------------------------------------------------------- 1 | check(); 18 | } 19 | 20 | /** 21 | * Get the validation rules that apply to the request. 22 | * 23 | * @return array 24 | */ 25 | public function rules() 26 | { 27 | $id = $this->get('id') ?? request()->route('id'); 28 | 29 | return [ 30 | 'email' => 'required|unique:'.config('backpack.permissionmanager.models.user', 'users').',email,'.$id, 31 | 'name' => 'required', 32 | 'password' => 'confirmed', 33 | ]; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/app/Models/Permission.php: -------------------------------------------------------------------------------- 1 | [ 15 | 'user' => config('backpack.base.user_model_fqn', \App\Models\User::class), 16 | 'permission' => Backpack\PermissionManager\app\Models\Permission::class, 17 | 'role' => Backpack\PermissionManager\app\Models\Role::class, 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Disallow the user interface for creating/updating permissions or roles. 23 | |-------------------------------------------------------------------------- 24 | | Roles and permissions are used in code by their name 25 | | - ex: $user->hasPermissionTo('edit articles'); 26 | | 27 | | So after the developer has entered all permissions and roles, the administrator should either: 28 | | - not have access to the panels 29 | | or 30 | | - creating and updating should be disabled 31 | */ 32 | 33 | 'allow_permission_create' => true, 34 | 'allow_permission_update' => true, 35 | 'allow_permission_delete' => true, 36 | 'allow_role_create' => true, 37 | 'allow_role_update' => true, 38 | 'allow_role_delete' => true, 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Multiple-guards functionality 43 | |-------------------------------------------------------------------------- 44 | | 45 | */ 46 | 'multiple_guards' => false, 47 | 48 | ]; 49 | -------------------------------------------------------------------------------- /src/database/migrations/2020_03_31_114745_remove_backpackuser_model.php: -------------------------------------------------------------------------------- 1 | replaceModels($model_has_roles); 23 | } 24 | if (\Illuminate\Support\Facades\Schema::hasTable($model_has_permissions)) { 25 | $this->replaceModels($model_has_permissions); 26 | } 27 | } 28 | 29 | public function replaceModels($table_name) 30 | { 31 | Log::info('Replacing BackpackUser model in '.$table_name); 32 | 33 | // if you've ended up with duplicate entries (both for App\User and App\Models\BackpackUser) 34 | // we can just delete them 35 | $userEntries = DB::table($table_name) 36 | ->where('model_type', "App\User") 37 | ->get(); 38 | 39 | foreach ($userEntries as $entry) { 40 | DB::table($table_name) 41 | ->where('role_id', $entry->role_id) 42 | ->where('model_type', 'App\Models\BackpackUser') 43 | ->where('model_id', $entry->model_id) 44 | ->delete(); 45 | } 46 | 47 | // for the rest of them, we can just replace the BackpackUser model with User 48 | DB::table($table_name) 49 | ->where('model_type', "App\Models\BackpackUser") 50 | ->update([ 51 | 'model_type' => "App\User", 52 | ]); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/resources/lang/ar/permissionmanager.php: -------------------------------------------------------------------------------- 1 | 11 | | 12 | */ 13 | 'name' => 'اسم', 14 | 'role' => 'وظيفة', 15 | 'roles' => 'وظائف', 16 | 'roles_have_permission' => 'الوظائف التي لديها هذه الصلاحية', 17 | 'permission_singular' => 'الصلاحية', 18 | 'permission_plural' => 'الصلاحيات', 19 | 'user_singular' => 'المستخدم', 20 | 'user_plural' => 'المستخدمين', 21 | 'email' => 'البريد الالكتروني', 22 | 'extra_permissions' => 'الصلاحيات الاضافية', 23 | 'password' => 'كلمة المرور', 24 | 'password_confirmation' => 'تأكيد كلمة المرور', 25 | 'user_role_permission' => 'صلاحيات دور المستخدم', 26 | 'user' => 'المستخدم', 27 | 'users' => 'المستخدمين', 28 | 'guard_type' => 'نوع الحماية', 29 | 30 | ]; 31 | -------------------------------------------------------------------------------- /src/resources/lang/da_DK/permissionmanager.php: -------------------------------------------------------------------------------- 1 | 11 | | 12 | */ 13 | 'name' => 'navn', 14 | 'role' => 'rolle', 15 | 'roles' => 'roller', 16 | 'roles_have_permission' => 'roller der har denne rettighed', 17 | 'permission_singular' => 'rettighed', 18 | 'permission_plural' => 'rettigheder', 19 | 'user_singular' => 'bruger', 20 | 'user_plural' => 'brugere', 21 | 'email' => 'E-mail', 22 | 'extra_permissions' => 'yderligere rettigheder', 23 | 'password' => 'password', 24 | 'password_confirmation' => 'gentag password', 25 | 'user_role_permission' => 'bruger rolle rettigheder', 26 | 'user' => 'bruger', 27 | 'users' => 'brugere', 28 | 29 | ]; 30 | -------------------------------------------------------------------------------- /src/resources/lang/de/permissionmanager.php: -------------------------------------------------------------------------------- 1 | 11 | | 12 | */ 13 | 'name' => 'Name', 14 | 'role' => 'Rolle', 15 | 'roles' => 'Rollen', 16 | 'roles_have_permission' => 'Rollen mit dieser Berechtigung', 17 | 'permission_singular' => 'Berechtigung', 18 | 'permission_plural' => 'Berechtigungen', 19 | 'user_singular' => 'Nutzer', 20 | 'user_plural' => 'Nutzer', 21 | 'email' => 'E-Mail', 22 | 'extra_permissions' => 'Zusätzliche Berechtigungen', 23 | 'password' => 'Passwort', 24 | 'password_confirmation' => 'Passwort bestätigen', 25 | 'user_role_permission' => 'Nutzer Rollen Berechtigungen', 26 | 'user' => 'Nutzer', 27 | 'users' => 'Nutzer', 28 | 29 | ]; 30 | -------------------------------------------------------------------------------- /src/resources/lang/el/permissionmanager.php: -------------------------------------------------------------------------------- 1 | 'Όνομα', 13 | 'role' => 'Ρόλος', 14 | 'roles' => 'Ρόλοι', 15 | 'roles_have_permission' => 'Ρόλοι με αυτό το δικαίωμα', 16 | 'permission_singular' => 'δικαίωμα', 17 | 'permission_plural' => 'Δικαιώματα', 18 | 'user_singular' => 'Χρήστης', 19 | 'user_plural' => 'Χρήστες', 20 | 'email' => 'Email', 21 | 'extra_permissions' => 'Πρόσθετα δικαιώματα', 22 | 'password' => 'Κωδικός', 23 | 'password_confirmation' => 'Επανάληψη κωδικού', 24 | 'user_role_permission' => 'Ρόλοι και Δικαιώματα Χρήστη', 25 | 'user' => 'Χρήστης', 26 | 'users' => 'Χρήστες', 27 | 28 | ]; 29 | -------------------------------------------------------------------------------- /src/resources/lang/en/permissionmanager.php: -------------------------------------------------------------------------------- 1 | 11 | | 12 | */ 13 | 'name' => 'Name', 14 | 'role' => 'Role', 15 | 'roles' => 'Roles', 16 | 'roles_have_permission' => 'Roles that have this permission', 17 | 'permission_singular' => 'Permission', 18 | 'permission_plural' => 'Permissions', 19 | 'user_singular' => 'User', 20 | 'user_plural' => 'Users', 21 | 'email' => 'Email', 22 | 'extra_permissions' => 'Extra Permissions', 23 | 'password' => 'Password', 24 | 'password_confirmation' => 'Password Confirmation', 25 | 'user_role_permission' => 'User Roles & Permissions', 26 | 'user' => 'User', 27 | 'users' => 'Users', 28 | 'guard_type' => 'Guard Type', 29 | 30 | ]; 31 | -------------------------------------------------------------------------------- /src/resources/lang/es/permissionmanager.php: -------------------------------------------------------------------------------- 1 | 'Nombre', 13 | 'role' => 'Rol', 14 | 'roles' => 'Roles', 15 | 'roles_have_permission' => 'Roles con este permiso', 16 | 'permission_singular' => 'Permiso', 17 | 'permission_plural' => 'Permisos', 18 | 'user_singular' => 'Usuario', 19 | 'user_plural' => 'Usuarios', 20 | 'email' => 'Correo electrónico', 21 | 'extra_permissions' => 'Permisos adicionales', 22 | 'password' => 'Contraseña', 23 | 'password_confirmation' => 'Confirmación de contraseña', 24 | 'user_role_permission' => 'Permisos del rol del usuario', 25 | 'user' => 'Usuario', 26 | 'users' => 'Usuarios', 27 | 28 | ]; 29 | -------------------------------------------------------------------------------- /src/resources/lang/fr/permissionmanager.php: -------------------------------------------------------------------------------- 1 | 11 | | 12 | */ 13 | 'name' => 'Nom', 14 | 'role' => 'Rôle', 15 | 'roles' => 'Rôles', 16 | 'roles_have_permission' => 'Rôles avec cette permission', 17 | 'permission_singular' => 'permission', 18 | 'permission_plural' => 'permissions', 19 | 'user_singular' => 'Utilisateur', 20 | 'user_plural' => 'Utilisateurs', 21 | 'email' => 'Email', 22 | 'extra_permissions' => 'Permissions supplémentaires', 23 | 'password' => 'Mot de passe', 24 | 'password_confirmation' => 'Confirmation du mot de passe', 25 | 'user_role_permission' => 'Rôles et permissions d’utilisateur', 26 | 'user' => 'Utilisateur', 27 | 'users' => 'Utilisateurs', 28 | 29 | ]; 30 | -------------------------------------------------------------------------------- /src/resources/lang/fr_CA/permissionmanager.php: -------------------------------------------------------------------------------- 1 | 11 | | 12 | */ 13 | 'name' => 'Nom', 14 | 'role' => 'Rôle', 15 | 'roles' => 'Rôles', 16 | 'roles_have_permission' => 'Rôles avec cette permission', 17 | 'permission_singular' => 'permission', 18 | 'permission_plural' => 'permissions', 19 | 'user_singular' => 'Utilisateur', 20 | 'user_plural' => 'Utilisateurs', 21 | 'email' => 'Email', 22 | 'extra_permissions' => 'Permissions supplémentaires', 23 | 'password' => 'Mot de passe', 24 | 'password_confirmation' => 'Confirmation du mot de passe', 25 | 'user_role_permission' => 'Rôles et permissions d’utilisateur', 26 | 'user' => 'Utilisateur', 27 | 'users' => 'Utilisateurs', 28 | 29 | ]; 30 | -------------------------------------------------------------------------------- /src/resources/lang/hu/permissionmanager.php: -------------------------------------------------------------------------------- 1 | 'Név', 14 | 'role' => 'Szerepkör', 15 | 'roles' => 'Szerepkörök', 16 | 'roles_have_permission' => 'Szerepkörök, melyek rendelkeznek ezzel a jogosultsággal', 17 | 'permission_singular' => 'Jogosultság', 18 | 'permission_plural' => 'Jogosultságok', 19 | 'user_singular' => 'Felhasználó', 20 | 'user_plural' => 'Felhasználók', 21 | 'email' => 'Email', 22 | 'extra_permissions' => 'Szerepkörön felüli jogosultság', 23 | 'password' => 'Jelszó', 24 | 'password_confirmation' => 'Jelszó megerősítése', 25 | 'user_role_permission' => 'Felhasználó Szerepkör Jogosultság', 26 | 'user' => 'Felhasználó', 27 | 'users' => 'Felhasználók', 28 | 'guard_type' => 'Guard típusa', 29 | 30 | ]; 31 | -------------------------------------------------------------------------------- /src/resources/lang/id/permissionmanager.php: -------------------------------------------------------------------------------- 1 | 11 | | 12 | */ 13 | 'name' => 'Nama', 14 | 'role' => 'Wewenang', 15 | 'roles' => 'Wewenang', 16 | 'roles_have_permission' => 'Wewenang yang memiliki izin ini', 17 | 'permission_singular' => 'izin', 18 | 'permission_plural' => 'izin', 19 | 'user_singular' => 'Pengguna', 20 | 'user_plural' => 'Pengguna', 21 | 'email' => 'Surel', 22 | 'extra_permissions' => 'Izin Ekstra', 23 | 'password' => 'Kata sandi', 24 | 'password_confirmation' => 'Konfirmasi kata sandi', 25 | 'user_role_permission' => 'Izin Peran Pengguna', 26 | 'user' => 'Pengguna', 27 | 'users' => 'Pengguna', 28 | 'guard_type' => 'Jenis Pelindung', 29 | 30 | ]; 31 | -------------------------------------------------------------------------------- /src/resources/lang/it/permissionmanager.php: -------------------------------------------------------------------------------- 1 | 'Nome', 16 | 'role' => 'Ruolo', 17 | 'roles' => 'Ruoli', 18 | 'roles_have_permission' => 'Ruoli con questo permesso', 19 | 'permission_singular' => 'Permesso', 20 | 'permission_plural' => 'Permessi', 21 | 'user_singular' => 'Utente', 22 | 'user_plural' => 'Utenti', 23 | 'email' => 'Email', 24 | 'extra_permissions' => 'Permessi Extra', 25 | 'password' => 'Password', 26 | 'password_confirmation' => 'Conferma Password', 27 | 'user_role_permission' => 'Utenti Ruoli Permessi', 28 | 'user' => 'Utente', 29 | 'users' => 'Utenti', 30 | 'guard_type' => 'Tipo Guard', 31 | ]; 32 | -------------------------------------------------------------------------------- /src/resources/lang/ja/permissionmanager.php: -------------------------------------------------------------------------------- 1 | '名前', 13 | 'role' => 'ロール', 14 | 'roles' => 'ロール', 15 | 'roles_have_permission' => 'この権限を持つロール', 16 | 'permission_singular' => '権限', 17 | 'permission_plural' => '権限', 18 | 'user_singular' => 'ユーザー', 19 | 'user_plural' => 'ユーザー', 20 | 'email' => 'メールアドレス', 21 | 'extra_permissions' => '追加の権限', 22 | 'password' => 'パスワード', 23 | 'password_confirmation' => 'パスワードの確認', 24 | 'user_role_permission' => 'ユーザーのロールと権限', 25 | 'user' => 'ユーザー', 26 | 'users' => 'ユーザー', 27 | 'guard_type' => 'Guard タイプ', 28 | 29 | ]; 30 | -------------------------------------------------------------------------------- /src/resources/lang/lv/permissionmanager.php: -------------------------------------------------------------------------------- 1 | 'Vārds', 13 | 'role' => 'Loma', 14 | 'roles' => 'Lomas', 15 | 'roles_have_permission' => 'Lomas kurām ir šī atļauja', 16 | 'permission_singular' => 'atļauja', 17 | 'permission_plural' => 'atļaujas', 18 | 'user_singular' => 'Lietotājs', 19 | 'user_plural' => 'Lietotāji', 20 | 'email' => 'E-pasts', 21 | 'extra_permissions' => 'Papildus atļaujas', 22 | 'password' => 'Parole', 23 | 'password_confirmation' => 'Parole otrreiz', 24 | 'user_role_permission' => 'Lietotāju lomas un atļaujas', 25 | 'user' => 'Lietotājs', 26 | 'users' => 'Lietotāji', 27 | 28 | ]; 29 | -------------------------------------------------------------------------------- /src/resources/lang/nl/permissionmanager.php: -------------------------------------------------------------------------------- 1 | 11 | | 12 | */ 13 | 'name' => 'Naam', 14 | 'role' => 'Rol', 15 | 'roles' => 'Rollen', 16 | 'roles_have_permission' => 'Rollen die deze permissie hebben', 17 | 'permission_singular' => 'Permissie', 18 | 'permission_plural' => 'Permissies', 19 | 'user_singular' => 'Gebruiker', 20 | 'user_plural' => 'Gebruikers', 21 | 'email' => 'E-mail', 22 | 'extra_permissions' => 'Extra permissies', 23 | 'password' => 'Wachtwoord', 24 | 'password_confirmation' => 'Wachtwoord bevestigen', 25 | 'user_role_permission' => 'Rollen en permissies voor gebruiker', 26 | 'user' => 'Gebruiker', 27 | 'users' => 'Gebruikers', 28 | 29 | ]; 30 | -------------------------------------------------------------------------------- /src/resources/lang/pt/permissionmanager.php: -------------------------------------------------------------------------------- 1 | 'Nome', 13 | 'role' => 'Cargo', 14 | 'roles' => 'Cargos', 15 | 'roles_have_permission' => 'Cargos com esta permissão', 16 | 'permission_singular' => 'permissão', 17 | 'permission_plural' => 'permissões', 18 | 'user_singular' => 'Utilizador', 19 | 'user_plural' => 'Utilizadores', 20 | 'email' => 'Email', 21 | 'extra_permissions' => 'Permissões extra', 22 | 'password' => 'Palavra-passe', 23 | 'password_confirmation' => 'Confirmar palavra-passe', 24 | 'user_role_permission' => 'Cargo e permissões do utilizador', 25 | 'user' => 'Utilizador', 26 | 'users' => 'Utilizadores', 27 | 'guard_type' => 'Tipo de guarda', 28 | 29 | ]; 30 | -------------------------------------------------------------------------------- /src/resources/lang/pt_br/permissionmanager.php: -------------------------------------------------------------------------------- 1 | 11 | | 12 | */ 13 | 14 | 'name' => 'Nome', 15 | 'role' => 'Grupo de Usuário', 16 | 'roles' => 'Grupos de Usuário', 17 | 'roles_have_permission' => 'Grupos que possuem esta permissão', 18 | 'permission_singular' => 'permissão', 19 | 'permission_plural' => 'permissões', 20 | 'user_singular' => 'Usuário', 21 | 'user_plural' => 'Usuários', 22 | 'email' => 'Email', 23 | 'extra_permissions' => 'Permissões Extras', 24 | 'password' => 'Senha', 25 | 'password_confirmation' => 'Confirmar senha', 26 | 'user_role_permission' => 'Permissões do Grupo de Usuário', 27 | 'user' => 'Usuário', 28 | 'users' => 'Usuários', 29 | 30 | ]; 31 | -------------------------------------------------------------------------------- /src/resources/lang/ru/permissionmanager.php: -------------------------------------------------------------------------------- 1 | , translating to Russian: Nikita K. 11 | | 12 | */ 13 | 'name' => 'Имя', 14 | 'role' => 'Роль', 15 | 'roles' => 'Роли', 16 | 'roles_have_permission' => 'Роли, которые имеют это разрешение', 17 | 'permission_singular' => 'разрешение', 18 | 'permission_plural' => 'разрешения', 19 | 'user_singular' => 'Пользователь', 20 | 'user_plural' => 'Пользователи', 21 | 'email' => 'Почта', 22 | 'extra_permissions' => 'Дополнительные разрешения', 23 | 'password' => 'Пароль', 24 | 'password_confirmation' => 'Повторите пароль', 25 | 'user_role_permission' => 'Разрешения роли пользователя', 26 | 'user' => 'Пользователь', 27 | 'users' => 'Пользователи', 28 | ]; 29 | -------------------------------------------------------------------------------- /src/resources/lang/sr/permissionmanager.php: -------------------------------------------------------------------------------- 1 | 11 | | 12 | */ 13 | 'name' => 'Ime', 14 | 'role' => 'Uloga', 15 | 'roles' => 'Uloge', 16 | 'roles_have_permission' => 'Uloge koje imaju prava', 17 | 'permission_singular' => 'Prava', 18 | 'permission_plural' => 'Prava', 19 | 'user_singular' => 'Korisnik', 20 | 'user_plural' => 'Korisnici', 21 | 'email' => 'E-pošta', 22 | 'extra_permissions' => 'Dodatne prava', 23 | 'password' => 'Lozinka', 24 | 'password_confirmation' => 'Potvrda lozinke', 25 | 'user_role_permission' => 'Korisnik uloga Prava', 26 | 'user' => 'Korisnik', 27 | 'users' => 'Korisnici', 28 | 'guard_type' => 'Tip garda', 29 | 30 | ]; 31 | -------------------------------------------------------------------------------- /src/resources/lang/tr/permissionmanager.php: -------------------------------------------------------------------------------- 1 | , translatin to Turkish : Selçuk Çukur 11 | | 12 | */ 13 | 'name' => 'Adı', 14 | 'role' => 'Yetki', 15 | 'roles' => 'Yetkiler', 16 | 'roles_have_permission' => 'Bu izne sahip yetkiler', 17 | 'permission_singular' => 'izin', 18 | 'permission_plural' => 'izinler', 19 | 'user_singular' => 'Kullanıcı', 20 | 'user_plural' => 'Kullanıcılar', 21 | 'email' => 'Eposta', 22 | 'extra_permissions' => 'Ekstra İzinler', 23 | 'password' => 'Parola', 24 | 'password_confirmation' => 'Parola (Tekrar)', 25 | 'user_role_permission' => 'Kullanıcı Yetki İzinleri', 26 | 'user' => 'Kullanıcı', 27 | 'users' => 'Kullanıcılar', 28 | 'guard_type' => 'Güvenlik Tipi', 29 | ]; 30 | -------------------------------------------------------------------------------- /src/resources/lang/uk/permissionmanager.php: -------------------------------------------------------------------------------- 1 | , translated to Ukrainian: Pavel Tkachenko 11 | | 12 | */ 13 | 'name' => "Ім'я", 14 | 'role' => 'Роль', 15 | 'roles' => 'Ролі', 16 | 'roles_have_permission' => 'Ролі, які мають цей дозвіл', 17 | 'permission_singular' => 'дозвіл', 18 | 'permission_plural' => 'дозволи', 19 | 'user_singular' => 'Користувач', 20 | 'user_plural' => 'Користувачі', 21 | 'email' => 'Електронна пошта', 22 | 'extra_permissions' => 'Додаткові дозволи', 23 | 'password' => 'Пароль', 24 | 'password_confirmation' => 'Підтвердження паролю', 25 | 'user_role_permission' => 'Дозволи ролі користувача', 26 | 'user' => 'Користувач', 27 | 'users' => 'Користувачі', 28 | 'guard_type' => 'Тип охорони', 29 | 30 | ]; 31 | -------------------------------------------------------------------------------- /src/resources/lang/vi/permissionmanager.php: -------------------------------------------------------------------------------- 1 | 11 | | 12 | */ 13 | 'name' => 'Tên', 14 | 'role' => 'Vai trò', 15 | 'roles' => 'Các vai trò', 16 | 'roles_have_permission' => 'Các vai trò được cấp quyền này', 17 | 'permission_singular' => 'Quyền', 18 | 'permission_plural' => 'Các quyền', 19 | 'user_singular' => 'Người dùng', 20 | 'user_plural' => 'Các người dùng', 21 | 'email' => 'Email', 22 | 'extra_permissions' => 'Các quyền bổ sung', 23 | 'password' => 'Mật khẩu', 24 | 'password_confirmation' => 'Xác nhận Mật khẩu', 25 | 'user_role_permission' => 'Người dùng, Vai trò, Các quyền', 26 | 'user' => 'Người dùng', 27 | 'users' => 'Các người dùng', 28 | 'guard_type' => 'Lớp bảo vệ', 29 | 30 | ]; 31 | -------------------------------------------------------------------------------- /src/resources/lang/zh-Hant/permissionmanager.php: -------------------------------------------------------------------------------- 1 | 11 | | 12 | */ 13 | 'name' => '名稱', 14 | 'role' => '角色', 15 | 'roles' => '角色', 16 | 'roles_have_permission' => '擁有此權限的角色', 17 | 'permission_singular' => '權限', 18 | 'permission_plural' => '權限', 19 | 'user_singular' => '使用者', 20 | 'user_plural' => '使用者', 21 | 'email' => 'Email', 22 | 'extra_permissions' => '額外權限', 23 | 'password' => '密碼', 24 | 'password_confirmation' => '再次輸入新密碼', 25 | 'user_role_permission' => '使用者角色與權限', 26 | 'user' => '使用者', 27 | 'users' => '使用者', 28 | 'guard_type' => 'Guard 類型', 29 | 30 | ]; 31 | -------------------------------------------------------------------------------- /src/resources/lang/zh-cn/permissionmanager.php: -------------------------------------------------------------------------------- 1 | 11 | | 12 | */ 13 | 'name' => '名称', 14 | 'role' => '角色', 15 | 'roles' => '角色', 16 | 'roles_have_permission' => '拥有此权限的角色', 17 | 'permission_singular' => '权限', 18 | 'permission_plural' => '权限', 19 | 'user_singular' => '用户', 20 | 'user_plural' => '用户', 21 | 'email' => '邮箱', 22 | 'extra_permissions' => '额外权限', 23 | 'password' => '密码', 24 | 'password_confirmation' => '再次输入新密码', 25 | 'user_role_permission' => '用户角色与权限', 26 | 'user' => '用户', 27 | 'users' => '用户', 28 | 'guard_type' => 'Guard 类型', 29 | 30 | ]; 31 | -------------------------------------------------------------------------------- /src/routes/backpack/permissionmanager.php: -------------------------------------------------------------------------------- 1 | 'Backpack\PermissionManager\app\Http\Controllers', 15 | 'prefix' => config('backpack.base.route_prefix', 'admin'), 16 | 'middleware' => ['web', backpack_middleware()], 17 | ], function () { 18 | Route::crud('permission', 'PermissionCrudController'); 19 | Route::crud('role', 'RoleCrudController'); 20 | Route::crud('user', 'UserCrudController'); 21 | }); 22 | --------------------------------------------------------------------------------