@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | |
| 5 | - /* |
|
| 5 | + /* |
|
| 6 | 6 | |-------------------------------------------------------------------------- |
| 7 | 7 | | Relations Between Models |
| 8 | 8 | |-------------------------------------------------------------------------- |
@@ -11,67 +11,67 @@ discard block |
||
| 11 | 11 | | |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | - 'relations' => [ |
|
| 15 | - 'user' => [ |
|
| 16 | - 'index' => [], |
|
| 17 | - 'show' => [], |
|
| 18 | - 'account' => [], |
|
| 19 | - ], |
|
| 20 | - 'permission' => [ |
|
| 21 | - 'index' => [], |
|
| 22 | - 'show' => [], |
|
| 23 | - ], |
|
| 24 | - 'role' => [ |
|
| 25 | - 'index' => [], |
|
| 26 | - 'show' => [], |
|
| 27 | - ], |
|
| 28 | - 'oauthClient' => [ |
|
| 29 | - 'index' => [], |
|
| 30 | - 'show' => [], |
|
| 31 | - ], |
|
| 32 | - 'notification' => [ |
|
| 33 | - 'index' => [], |
|
| 34 | - 'unread' => [], |
|
| 35 | - ], |
|
| 36 | - 'pushNotificationDevice' => [ |
|
| 37 | - 'index' => [], |
|
| 38 | - 'show' => [], |
|
| 39 | - ], |
|
| 40 | - 'report' => [ |
|
| 41 | - 'index' => [], |
|
| 42 | - 'show' => [], |
|
| 43 | - ], |
|
| 44 | - 'setting' => [ |
|
| 45 | - 'index' => [], |
|
| 46 | - 'show' => [], |
|
| 47 | - ], |
|
| 48 | - 'projectType' => [ |
|
| 49 | - 'index' => [], |
|
| 50 | - 'show' => [], |
|
| 51 | - ], |
|
| 52 | - 'spaceType' => [ |
|
| 53 | - 'index' => [], |
|
| 54 | - 'show' => [], |
|
| 55 | - ], |
|
| 56 | - 'section' => [ |
|
| 57 | - 'index' => ['styles'], |
|
| 58 | - 'show' => ['styles'], |
|
| 59 | - ], |
|
| 60 | - 'style' => [ |
|
| 61 | - 'index' => [], |
|
| 62 | - 'show' => [], |
|
| 63 | - ], |
|
| 64 | - 'request' => [ |
|
| 65 | - 'index' => [], |
|
| 66 | - 'show' => ['sections'], |
|
| 67 | - ], |
|
| 68 | - 'fileManager' => [ |
|
| 69 | - 'index' => [], |
|
| 70 | - 'show' => [], |
|
| 71 | - ], |
|
| 72 | - ], |
|
| 14 | + 'relations' => [ |
|
| 15 | + 'user' => [ |
|
| 16 | + 'index' => [], |
|
| 17 | + 'show' => [], |
|
| 18 | + 'account' => [], |
|
| 19 | + ], |
|
| 20 | + 'permission' => [ |
|
| 21 | + 'index' => [], |
|
| 22 | + 'show' => [], |
|
| 23 | + ], |
|
| 24 | + 'role' => [ |
|
| 25 | + 'index' => [], |
|
| 26 | + 'show' => [], |
|
| 27 | + ], |
|
| 28 | + 'oauthClient' => [ |
|
| 29 | + 'index' => [], |
|
| 30 | + 'show' => [], |
|
| 31 | + ], |
|
| 32 | + 'notification' => [ |
|
| 33 | + 'index' => [], |
|
| 34 | + 'unread' => [], |
|
| 35 | + ], |
|
| 36 | + 'pushNotificationDevice' => [ |
|
| 37 | + 'index' => [], |
|
| 38 | + 'show' => [], |
|
| 39 | + ], |
|
| 40 | + 'report' => [ |
|
| 41 | + 'index' => [], |
|
| 42 | + 'show' => [], |
|
| 43 | + ], |
|
| 44 | + 'setting' => [ |
|
| 45 | + 'index' => [], |
|
| 46 | + 'show' => [], |
|
| 47 | + ], |
|
| 48 | + 'projectType' => [ |
|
| 49 | + 'index' => [], |
|
| 50 | + 'show' => [], |
|
| 51 | + ], |
|
| 52 | + 'spaceType' => [ |
|
| 53 | + 'index' => [], |
|
| 54 | + 'show' => [], |
|
| 55 | + ], |
|
| 56 | + 'section' => [ |
|
| 57 | + 'index' => ['styles'], |
|
| 58 | + 'show' => ['styles'], |
|
| 59 | + ], |
|
| 60 | + 'style' => [ |
|
| 61 | + 'index' => [], |
|
| 62 | + 'show' => [], |
|
| 63 | + ], |
|
| 64 | + 'request' => [ |
|
| 65 | + 'index' => [], |
|
| 66 | + 'show' => ['sections'], |
|
| 67 | + ], |
|
| 68 | + 'fileManager' => [ |
|
| 69 | + 'index' => [], |
|
| 70 | + 'show' => [], |
|
| 71 | + ], |
|
| 72 | + ], |
|
| 73 | 73 | |
| 74 | - /* |
|
| 74 | + /* |
|
| 75 | 75 | |-------------------------------------------------------------------------- |
| 76 | 76 | | Cache Configurations |
| 77 | 77 | |-------------------------------------------------------------------------- |
@@ -80,104 +80,104 @@ discard block |
||
| 80 | 80 | | |
| 81 | 81 | */ |
| 82 | 82 | |
| 83 | - 'cache_config' => [ |
|
| 84 | - 'oauthClient' => [ |
|
| 85 | - 'cache' => [ |
|
| 86 | - 'list', |
|
| 87 | - 'find', |
|
| 88 | - 'findBy', |
|
| 89 | - 'paginate', |
|
| 90 | - 'paginateBy', |
|
| 91 | - 'first', |
|
| 92 | - 'deleted' |
|
| 93 | - ], |
|
| 94 | - 'clear' => [ |
|
| 95 | - 'save' => ['oauthClient'], |
|
| 96 | - 'delete' => ['oauthClient'], |
|
| 97 | - 'restore' => ['oauthClient'], |
|
| 98 | - 'revoke' => ['oauthClient'], |
|
| 99 | - 'ubRevoke' => ['oauthClient'], |
|
| 100 | - 'regenerateSecret' => ['oauthClient'], |
|
| 101 | - ], |
|
| 102 | - ], |
|
| 103 | - 'setting' => [ |
|
| 104 | - 'cache' => [ |
|
| 105 | - 'list', |
|
| 106 | - 'find', |
|
| 107 | - 'findBy', |
|
| 108 | - 'paginate', |
|
| 109 | - 'paginateBy', |
|
| 110 | - 'first', |
|
| 111 | - 'deleted' |
|
| 112 | - ], |
|
| 113 | - 'clear' => [ |
|
| 114 | - 'save' => ['setting'], |
|
| 115 | - 'saveMany' => ['setting'], |
|
| 116 | - ] |
|
| 117 | - ], |
|
| 118 | - 'projectType' => [ |
|
| 119 | - 'cache' => [ |
|
| 120 | - 'list', |
|
| 121 | - 'find', |
|
| 122 | - 'findBy', |
|
| 123 | - 'paginate', |
|
| 124 | - 'paginateBy', |
|
| 125 | - 'first', |
|
| 126 | - 'deleted' |
|
| 127 | - ], |
|
| 128 | - 'clear' => [ |
|
| 129 | - 'save' => ['projectType'], |
|
| 130 | - 'delete' => ['projectType'], |
|
| 131 | - 'restore' => ['projectType'] |
|
| 132 | - ], |
|
| 133 | - ], |
|
| 134 | - 'spaceType' => [ |
|
| 135 | - 'cache' => [ |
|
| 136 | - 'list', |
|
| 137 | - 'find', |
|
| 138 | - 'findBy', |
|
| 139 | - 'paginate', |
|
| 140 | - 'paginateBy', |
|
| 141 | - 'first', |
|
| 142 | - 'deleted' |
|
| 143 | - ], |
|
| 144 | - 'clear' => [ |
|
| 145 | - 'save' => ['spaceType', 'section'], |
|
| 146 | - 'delete' => ['spaceType', 'section'], |
|
| 147 | - 'restore' => ['spaceType', 'section'] |
|
| 148 | - ], |
|
| 149 | - ], |
|
| 150 | - 'section' => [ |
|
| 151 | - 'cache' => [ |
|
| 152 | - 'list', |
|
| 153 | - 'find', |
|
| 154 | - 'findBy', |
|
| 155 | - 'paginate', |
|
| 156 | - 'paginateBy', |
|
| 157 | - 'first', |
|
| 158 | - 'deleted' |
|
| 159 | - ], |
|
| 160 | - 'clear' => [ |
|
| 161 | - 'save' => ['section', 'spaceType', 'style'], |
|
| 162 | - 'delete' => ['section', 'spaceType', 'style'], |
|
| 163 | - 'restore' => ['section', 'spaceType', 'style'] |
|
| 164 | - ], |
|
| 165 | - ], |
|
| 166 | - 'style' => [ |
|
| 167 | - 'cache' => [ |
|
| 168 | - 'list', |
|
| 169 | - 'find', |
|
| 170 | - 'findBy', |
|
| 171 | - 'paginate', |
|
| 172 | - 'paginateBy', |
|
| 173 | - 'first', |
|
| 174 | - 'deleted' |
|
| 175 | - ], |
|
| 176 | - 'clear' => [ |
|
| 177 | - 'save' => ['style', 'section'], |
|
| 178 | - 'delete' => ['style', 'section'], |
|
| 179 | - 'restore' => ['style', 'section'] |
|
| 180 | - ], |
|
| 181 | - ], |
|
| 182 | - ] |
|
| 83 | + 'cache_config' => [ |
|
| 84 | + 'oauthClient' => [ |
|
| 85 | + 'cache' => [ |
|
| 86 | + 'list', |
|
| 87 | + 'find', |
|
| 88 | + 'findBy', |
|
| 89 | + 'paginate', |
|
| 90 | + 'paginateBy', |
|
| 91 | + 'first', |
|
| 92 | + 'deleted' |
|
| 93 | + ], |
|
| 94 | + 'clear' => [ |
|
| 95 | + 'save' => ['oauthClient'], |
|
| 96 | + 'delete' => ['oauthClient'], |
|
| 97 | + 'restore' => ['oauthClient'], |
|
| 98 | + 'revoke' => ['oauthClient'], |
|
| 99 | + 'ubRevoke' => ['oauthClient'], |
|
| 100 | + 'regenerateSecret' => ['oauthClient'], |
|
| 101 | + ], |
|
| 102 | + ], |
|
| 103 | + 'setting' => [ |
|
| 104 | + 'cache' => [ |
|
| 105 | + 'list', |
|
| 106 | + 'find', |
|
| 107 | + 'findBy', |
|
| 108 | + 'paginate', |
|
| 109 | + 'paginateBy', |
|
| 110 | + 'first', |
|
| 111 | + 'deleted' |
|
| 112 | + ], |
|
| 113 | + 'clear' => [ |
|
| 114 | + 'save' => ['setting'], |
|
| 115 | + 'saveMany' => ['setting'], |
|
| 116 | + ] |
|
| 117 | + ], |
|
| 118 | + 'projectType' => [ |
|
| 119 | + 'cache' => [ |
|
| 120 | + 'list', |
|
| 121 | + 'find', |
|
| 122 | + 'findBy', |
|
| 123 | + 'paginate', |
|
| 124 | + 'paginateBy', |
|
| 125 | + 'first', |
|
| 126 | + 'deleted' |
|
| 127 | + ], |
|
| 128 | + 'clear' => [ |
|
| 129 | + 'save' => ['projectType'], |
|
| 130 | + 'delete' => ['projectType'], |
|
| 131 | + 'restore' => ['projectType'] |
|
| 132 | + ], |
|
| 133 | + ], |
|
| 134 | + 'spaceType' => [ |
|
| 135 | + 'cache' => [ |
|
| 136 | + 'list', |
|
| 137 | + 'find', |
|
| 138 | + 'findBy', |
|
| 139 | + 'paginate', |
|
| 140 | + 'paginateBy', |
|
| 141 | + 'first', |
|
| 142 | + 'deleted' |
|
| 143 | + ], |
|
| 144 | + 'clear' => [ |
|
| 145 | + 'save' => ['spaceType', 'section'], |
|
| 146 | + 'delete' => ['spaceType', 'section'], |
|
| 147 | + 'restore' => ['spaceType', 'section'] |
|
| 148 | + ], |
|
| 149 | + ], |
|
| 150 | + 'section' => [ |
|
| 151 | + 'cache' => [ |
|
| 152 | + 'list', |
|
| 153 | + 'find', |
|
| 154 | + 'findBy', |
|
| 155 | + 'paginate', |
|
| 156 | + 'paginateBy', |
|
| 157 | + 'first', |
|
| 158 | + 'deleted' |
|
| 159 | + ], |
|
| 160 | + 'clear' => [ |
|
| 161 | + 'save' => ['section', 'spaceType', 'style'], |
|
| 162 | + 'delete' => ['section', 'spaceType', 'style'], |
|
| 163 | + 'restore' => ['section', 'spaceType', 'style'] |
|
| 164 | + ], |
|
| 165 | + ], |
|
| 166 | + 'style' => [ |
|
| 167 | + 'cache' => [ |
|
| 168 | + 'list', |
|
| 169 | + 'find', |
|
| 170 | + 'findBy', |
|
| 171 | + 'paginate', |
|
| 172 | + 'paginateBy', |
|
| 173 | + 'first', |
|
| 174 | + 'deleted' |
|
| 175 | + ], |
|
| 176 | + 'clear' => [ |
|
| 177 | + 'save' => ['style', 'section'], |
|
| 178 | + 'delete' => ['style', 'section'], |
|
| 179 | + 'restore' => ['style', 'section'] |
|
| 180 | + ], |
|
| 181 | + ], |
|
| 182 | + ] |
|
| 183 | 183 | ]; |
@@ -7,43 +7,43 @@ |
||
| 7 | 7 | |
| 8 | 8 | class RoleRepository extends BaseRepository implements RoleRepositoryInterface |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * Init new object. |
|
| 12 | - * |
|
| 13 | - * @param Role $model |
|
| 14 | - * @return void |
|
| 15 | - */ |
|
| 16 | - public function __construct(Role $model) |
|
| 17 | - { |
|
| 18 | - parent::__construct($model); |
|
| 19 | - } |
|
| 10 | + /** |
|
| 11 | + * Init new object. |
|
| 12 | + * |
|
| 13 | + * @param Role $model |
|
| 14 | + * @return void |
|
| 15 | + */ |
|
| 16 | + public function __construct(Role $model) |
|
| 17 | + { |
|
| 18 | + parent::__construct($model); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Detach all permissions from the given role. |
|
| 23 | - * |
|
| 24 | - * @param mixed $role |
|
| 25 | - * @return bool |
|
| 26 | - */ |
|
| 27 | - public function detachPermissions(mixed $role): bool |
|
| 28 | - { |
|
| 29 | - $role = ! filter_var($role, FILTER_VALIDATE_INT) ? $role : $this->find($role); |
|
| 30 | - $role->permissions()->detach(); |
|
| 21 | + /** |
|
| 22 | + * Detach all permissions from the given role. |
|
| 23 | + * |
|
| 24 | + * @param mixed $role |
|
| 25 | + * @return bool |
|
| 26 | + */ |
|
| 27 | + public function detachPermissions(mixed $role): bool |
|
| 28 | + { |
|
| 29 | + $role = ! filter_var($role, FILTER_VALIDATE_INT) ? $role : $this->find($role); |
|
| 30 | + $role->permissions()->detach(); |
|
| 31 | 31 | |
| 32 | - return true; |
|
| 33 | - } |
|
| 32 | + return true; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Attach permission ids to the given role. |
|
| 37 | - * |
|
| 38 | - * @param mixed $role |
|
| 39 | - * @param array $permissionIds |
|
| 40 | - * @return bool |
|
| 41 | - */ |
|
| 42 | - public function attachPermissions(mixed $role, array $permissionIds): bool |
|
| 43 | - { |
|
| 44 | - $role = ! filter_var($role, FILTER_VALIDATE_INT) ? $role : $this->find($role); |
|
| 45 | - $role->permissions()->attach($permissionIds); |
|
| 35 | + /** |
|
| 36 | + * Attach permission ids to the given role. |
|
| 37 | + * |
|
| 38 | + * @param mixed $role |
|
| 39 | + * @param array $permissionIds |
|
| 40 | + * @return bool |
|
| 41 | + */ |
|
| 42 | + public function attachPermissions(mixed $role, array $permissionIds): bool |
|
| 43 | + { |
|
| 44 | + $role = ! filter_var($role, FILTER_VALIDATE_INT) ? $role : $this->find($role); |
|
| 45 | + $role->permissions()->attach($permissionIds); |
|
| 46 | 46 | |
| 47 | - return true; |
|
| 48 | - } |
|
| 47 | + return true; |
|
| 48 | + } |
|
| 49 | 49 | } |
@@ -6,20 +6,20 @@ |
||
| 6 | 6 | |
| 7 | 7 | interface RoleRepositoryInterface extends BaseRepositoryInterface |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Detach all permissions from the given role. |
|
| 11 | - * |
|
| 12 | - * @param mixed $role |
|
| 13 | - * @return bool |
|
| 14 | - */ |
|
| 15 | - public function detachPermissions(mixed $role): bool; |
|
| 9 | + /** |
|
| 10 | + * Detach all permissions from the given role. |
|
| 11 | + * |
|
| 12 | + * @param mixed $role |
|
| 13 | + * @return bool |
|
| 14 | + */ |
|
| 15 | + public function detachPermissions(mixed $role): bool; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Attach permission ids to the given role. |
|
| 19 | - * |
|
| 20 | - * @param mixed $role |
|
| 21 | - * @param array $permissionIds |
|
| 22 | - * @return bool |
|
| 23 | - */ |
|
| 24 | - public function attachPermissions(mixed $role, array $permissionIds): bool; |
|
| 17 | + /** |
|
| 18 | + * Attach permission ids to the given role. |
|
| 19 | + * |
|
| 20 | + * @param mixed $role |
|
| 21 | + * @param array $permissionIds |
|
| 22 | + * @return bool |
|
| 23 | + */ |
|
| 24 | + public function attachPermissions(mixed $role, array $permissionIds): bool; |
|
| 25 | 25 | } |
@@ -8,40 +8,40 @@ |
||
| 8 | 8 | |
| 9 | 9 | class RoleController extends BaseApiController |
| 10 | 10 | { |
| 11 | - /** |
|
| 12 | - * Path of the sotre form request. |
|
| 13 | - * |
|
| 14 | - * @var string |
|
| 15 | - */ |
|
| 16 | - protected $storeFormRequest = 'App\Modules\Roles\Http\Requests\StoreRole'; |
|
| 11 | + /** |
|
| 12 | + * Path of the sotre form request. |
|
| 13 | + * |
|
| 14 | + * @var string |
|
| 15 | + */ |
|
| 16 | + protected $storeFormRequest = 'App\Modules\Roles\Http\Requests\StoreRole'; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Path of the model resource |
|
| 20 | - * |
|
| 21 | - * @var string |
|
| 22 | - */ |
|
| 23 | - protected $modelResource = 'App\Modules\Roles\Http\Resources\Role'; |
|
| 18 | + /** |
|
| 19 | + * Path of the model resource |
|
| 20 | + * |
|
| 21 | + * @var string |
|
| 22 | + */ |
|
| 23 | + protected $modelResource = 'App\Modules\Roles\Http\Resources\Role'; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Init new object. |
|
| 27 | - * |
|
| 28 | - * @param RoleServiceInterface $service |
|
| 29 | - * @return void |
|
| 30 | - */ |
|
| 31 | - public function __construct(RoleServiceInterface $service) |
|
| 32 | - { |
|
| 33 | - parent::__construct($service); |
|
| 34 | - } |
|
| 25 | + /** |
|
| 26 | + * Init new object. |
|
| 27 | + * |
|
| 28 | + * @param RoleServiceInterface $service |
|
| 29 | + * @return void |
|
| 30 | + */ |
|
| 31 | + public function __construct(RoleServiceInterface $service) |
|
| 32 | + { |
|
| 33 | + parent::__construct($service); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Handle an assign permissions to role request. |
|
| 38 | - * |
|
| 39 | - * @param AssignPermissions $request |
|
| 40 | - * @param integer $id |
|
| 41 | - * @return \Illuminate\Http\Response |
|
| 42 | - */ |
|
| 43 | - public function assignPermissions(AssignPermissions $request, $id) |
|
| 44 | - { |
|
| 45 | - return new $this->modelResource($this->service->assignPermissions($id, $request->get('permission_ids'))); |
|
| 46 | - } |
|
| 36 | + /** |
|
| 37 | + * Handle an assign permissions to role request. |
|
| 38 | + * |
|
| 39 | + * @param AssignPermissions $request |
|
| 40 | + * @param integer $id |
|
| 41 | + * @return \Illuminate\Http\Response |
|
| 42 | + */ |
|
| 43 | + public function assignPermissions(AssignPermissions $request, $id) |
|
| 44 | + { |
|
| 45 | + return new $this->modelResource($this->service->assignPermissions($id, $request->get('permission_ids'))); |
|
| 46 | + } |
|
| 47 | 47 | } |
@@ -9,33 +9,33 @@ |
||
| 9 | 9 | |
| 10 | 10 | class RoleService extends BaseService implements RoleServiceInterface |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * Init new object. |
|
| 14 | - * |
|
| 15 | - * @param RoleRepositoryInterface $repo |
|
| 16 | - * @return void |
|
| 17 | - */ |
|
| 18 | - public function __construct(RoleRepositoryInterface $repo) |
|
| 19 | - { |
|
| 20 | - parent::__construct($repo); |
|
| 21 | - } |
|
| 12 | + /** |
|
| 13 | + * Init new object. |
|
| 14 | + * |
|
| 15 | + * @param RoleRepositoryInterface $repo |
|
| 16 | + * @return void |
|
| 17 | + */ |
|
| 18 | + public function __construct(RoleRepositoryInterface $repo) |
|
| 19 | + { |
|
| 20 | + parent::__construct($repo); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Assign the given permission ids to the given role. |
|
| 25 | - * |
|
| 26 | - * @param integer $roleId |
|
| 27 | - * @param array $permissionIds |
|
| 28 | - * @return Model |
|
| 29 | - */ |
|
| 30 | - public function assignPermissions(int $roleId, array $permissionIds): Model |
|
| 31 | - { |
|
| 32 | - $role = new Model(); |
|
| 33 | - DB::transaction(function () use ($roleId, $permissionIds, &$role) { |
|
| 34 | - $role = $this->repo->find($roleId); |
|
| 35 | - $this->repo->detachPermissions($role); |
|
| 36 | - $this->repo->attachPermissions($role, $permissionIds); |
|
| 37 | - }); |
|
| 23 | + /** |
|
| 24 | + * Assign the given permission ids to the given role. |
|
| 25 | + * |
|
| 26 | + * @param integer $roleId |
|
| 27 | + * @param array $permissionIds |
|
| 28 | + * @return Model |
|
| 29 | + */ |
|
| 30 | + public function assignPermissions(int $roleId, array $permissionIds): Model |
|
| 31 | + { |
|
| 32 | + $role = new Model(); |
|
| 33 | + DB::transaction(function () use ($roleId, $permissionIds, &$role) { |
|
| 34 | + $role = $this->repo->find($roleId); |
|
| 35 | + $this->repo->detachPermissions($role); |
|
| 36 | + $this->repo->attachPermissions($role, $permissionIds); |
|
| 37 | + }); |
|
| 38 | 38 | |
| 39 | - return $role; |
|
| 40 | - } |
|
| 39 | + return $role; |
|
| 40 | + } |
|
| 41 | 41 | } |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | public function assignPermissions(int $roleId, array $permissionIds): Model |
| 31 | 31 | { |
| 32 | 32 | $role = new Model(); |
| 33 | - DB::transaction(function () use ($roleId, $permissionIds, &$role) { |
|
| 33 | + DB::transaction(function() use ($roleId, $permissionIds, &$role) { |
|
| 34 | 34 | $role = $this->repo->find($roleId); |
| 35 | 35 | $this->repo->detachPermissions($role); |
| 36 | 36 | $this->repo->attachPermissions($role, $permissionIds); |
@@ -8,12 +8,12 @@ |
||
| 8 | 8 | interface RoleServiceInterface extends BaseServiceInterface |
| 9 | 9 | { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * Assign the given permission ids to the given role. |
|
| 13 | - * |
|
| 14 | - * @param integer $roleId |
|
| 15 | - * @param array $permissionIds |
|
| 16 | - * @return Model |
|
| 17 | - */ |
|
| 18 | - public function assignPermissions(int $roleId, array $permissionIds): Model; |
|
| 11 | + /** |
|
| 12 | + * Assign the given permission ids to the given role. |
|
| 13 | + * |
|
| 14 | + * @param integer $roleId |
|
| 15 | + * @param array $permissionIds |
|
| 16 | + * @return Model |
|
| 17 | + */ |
|
| 18 | + public function assignPermissions(int $roleId, array $permissionIds): Model; |
|
| 19 | 19 | } |
@@ -10,35 +10,35 @@ |
||
| 10 | 10 | |
| 11 | 11 | class ModuleServiceProvider extends ServiceProvider |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * Bootstrap the module services. |
|
| 15 | - * |
|
| 16 | - * @return void |
|
| 17 | - */ |
|
| 18 | - public function boot() |
|
| 19 | - { |
|
| 20 | - $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'roles'); |
|
| 21 | - $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'roles'); |
|
| 13 | + /** |
|
| 14 | + * Bootstrap the module services. |
|
| 15 | + * |
|
| 16 | + * @return void |
|
| 17 | + */ |
|
| 18 | + public function boot() |
|
| 19 | + { |
|
| 20 | + $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'roles'); |
|
| 21 | + $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'roles'); |
|
| 22 | 22 | |
| 23 | - $this->loadMigrationsFrom(module_path('roles', 'Database/Migrations', 'app')); |
|
| 24 | - if (!$this->app->configurationIsCached()) { |
|
| 25 | - $this->loadConfigsFrom(module_path('roles', 'Config', 'app')); |
|
| 26 | - } |
|
| 27 | - } |
|
| 23 | + $this->loadMigrationsFrom(module_path('roles', 'Database/Migrations', 'app')); |
|
| 24 | + if (!$this->app->configurationIsCached()) { |
|
| 25 | + $this->loadConfigsFrom(module_path('roles', 'Config', 'app')); |
|
| 26 | + } |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Register the module services. |
|
| 31 | - * |
|
| 32 | - * @return void |
|
| 33 | - */ |
|
| 34 | - public function register() |
|
| 35 | - { |
|
| 36 | - $this->app->register(RouteServiceProvider::class); |
|
| 29 | + /** |
|
| 30 | + * Register the module services. |
|
| 31 | + * |
|
| 32 | + * @return void |
|
| 33 | + */ |
|
| 34 | + public function register() |
|
| 35 | + { |
|
| 36 | + $this->app->register(RouteServiceProvider::class); |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Bind interfaces to implmentations. |
|
| 40 | - */ |
|
| 41 | - $this->app->bind(RoleServiceInterface::class, RoleService::class); |
|
| 42 | - $this->app->bind(RoleRepositoryInterface::class, RoleRepository::class); |
|
| 43 | - } |
|
| 38 | + /** |
|
| 39 | + * Bind interfaces to implmentations. |
|
| 40 | + */ |
|
| 41 | + $this->app->bind(RoleServiceInterface::class, RoleService::class); |
|
| 42 | + $this->app->bind(RoleRepositoryInterface::class, RoleRepository::class); |
|
| 43 | + } |
|
| 44 | 44 | } |
@@ -7,14 +7,14 @@ |
||
| 7 | 7 | |
| 8 | 8 | class PermissionRepository extends BaseRepository implements PermissionRepositoryInterface |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * Init new object. |
|
| 12 | - * |
|
| 13 | - * @param Permission $model |
|
| 14 | - * @return void |
|
| 15 | - */ |
|
| 16 | - public function __construct(Permission $model) |
|
| 17 | - { |
|
| 18 | - parent::__construct($model); |
|
| 19 | - } |
|
| 10 | + /** |
|
| 11 | + * Init new object. |
|
| 12 | + * |
|
| 13 | + * @param Permission $model |
|
| 14 | + * @return void |
|
| 15 | + */ |
|
| 16 | + public function __construct(Permission $model) |
|
| 17 | + { |
|
| 18 | + parent::__construct($model); |
|
| 19 | + } |
|
| 20 | 20 | } |
@@ -7,21 +7,21 @@ |
||
| 7 | 7 | |
| 8 | 8 | class PermissionController extends BaseApiController |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * Path of the model resource |
|
| 12 | - * |
|
| 13 | - * @var string |
|
| 14 | - */ |
|
| 15 | - protected $modelResource = 'App\Modules\Permissions\Http\Resources\Permission'; |
|
| 10 | + /** |
|
| 11 | + * Path of the model resource |
|
| 12 | + * |
|
| 13 | + * @var string |
|
| 14 | + */ |
|
| 15 | + protected $modelResource = 'App\Modules\Permissions\Http\Resources\Permission'; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Init new object. |
|
| 19 | - * |
|
| 20 | - * @param PermissionServiceInterface $service |
|
| 21 | - * @return void |
|
| 22 | - */ |
|
| 23 | - public function __construct(PermissionServiceInterface $service) |
|
| 24 | - { |
|
| 25 | - parent::__construct($service); |
|
| 26 | - } |
|
| 17 | + /** |
|
| 18 | + * Init new object. |
|
| 19 | + * |
|
| 20 | + * @param PermissionServiceInterface $service |
|
| 21 | + * @return void |
|
| 22 | + */ |
|
| 23 | + public function __construct(PermissionServiceInterface $service) |
|
| 24 | + { |
|
| 25 | + parent::__construct($service); |
|
| 26 | + } |
|
| 27 | 27 | } |