| @@ -89,9 +89,9 @@ discard block | ||
| 89 | 89 | |
| 90 | 90 | // First we need to check restritions for given Role | 
| 91 | 91 | // to detect special Location, IP, Hours conditions. | 
| 92 | - if (! $this->checkRestrictions()) return $this->denied; | |
| 92 | + if (!$this->checkRestrictions()) return $this->denied; | |
| 93 | 93 | |
| 94 | - return $this->hasModel($model, $relation) ? $this->allowed: $this->denied; | |
| 94 | + return $this->hasModel($model, $relation) ? $this->allowed : $this->denied; | |
| 95 | 95 | } | 
| 96 | 96 | |
| 97 | 97 | /** | 
| @@ -108,7 +108,7 @@ discard block | ||
| 108 | 108 | |
| 109 | 109 | // First we need to check restritions for given Role | 
| 110 | 110 | // to detect special Location, IP, Hours conditions. | 
| 111 | - if (! $this->checkRestrictions()) return $this->denied; | |
| 111 | + if (!$this->checkRestrictions()) return $this->denied; | |
| 112 | 112 | |
| 113 | 113 | if ($this->hasModel($model, $relation)) return $this->allowed; | 
| 114 | 114 | |
| @@ -128,7 +128,7 @@ discard block | ||
| 128 | 128 | |
| 129 | 129 | // First we need to check restritions for given Role | 
| 130 | 130 | // to detect special Location, IP, Hours conditions. | 
| 131 | - if (! $this->checkRestrictions()) return $this->denied; | |
| 131 | + if (!$this->checkRestrictions()) return $this->denied; | |
| 132 | 132 | |
| 133 | 133 | return $this->hasLevel($min) ? $this->allowed : $this->denied; | 
| 134 | 134 | } | 
| @@ -147,7 +147,7 @@ discard block | ||
| 147 | 147 | |
| 148 | 148 | // First we need to check restritions for given Role | 
| 149 | 149 | // to detect special Location, IP, Hours conditions. | 
| 150 | - if (! $this->checkRestrictions()) return $this->denied; | |
| 150 | + if (!$this->checkRestrictions()) return $this->denied; | |
| 151 | 151 | |
| 152 | 152 | return $this->isOwner($model, $foreign) ? $this->allowed : $this->denied; | 
| 153 | 153 | } | 
| @@ -167,7 +167,7 @@ discard block | ||
| 167 | 167 | |
| 168 | 168 | // First we need to check restritions for given Role | 
| 169 | 169 | // to detect special Location, IP, Hours conditions. | 
| 170 | - if (! $this->checkRestrictions()) return $this->denied; | |
| 170 | + if (!$this->checkRestrictions()) return $this->denied; | |
| 171 | 171 | |
| 172 | 172 | if ($this->isOwner($model, $foreign)) return $this->allowed; | 
| 173 | 173 | |
| @@ -202,7 +202,7 @@ discard block | ||
| 202 | 202 | |
| 203 | 203 | // First we need to check restritions for given Role | 
| 204 | 204 | // to detect special Location, IP, Hours conditions. | 
| 205 | - if (! $this->checkRestrictions()) return $this->denied; | |
| 205 | + if (!$this->checkRestrictions()) return $this->denied; | |
| 206 | 206 | |
| 207 | 207 | return $this->isSharing($model, $modelRelation, $relation) ? | 
| 208 | 208 | $this->allowed : $this->denied; | 
| @@ -89,7 +89,9 @@ discard block | ||
| 89 | 89 | |
| 90 | 90 | // First we need to check restritions for given Role | 
| 91 | 91 | // to detect special Location, IP, Hours conditions. | 
| 92 | - if (! $this->checkRestrictions()) return $this->denied; | |
| 92 | +        if (! $this->checkRestrictions()) { | |
| 93 | + return $this->denied; | |
| 94 | + } | |
| 93 | 95 | |
| 94 | 96 | return $this->hasModel($model, $relation) ? $this->allowed: $this->denied; | 
| 95 | 97 | } | 
| @@ -108,9 +110,13 @@ discard block | ||
| 108 | 110 | |
| 109 | 111 | // First we need to check restritions for given Role | 
| 110 | 112 | // to detect special Location, IP, Hours conditions. | 
| 111 | - if (! $this->checkRestrictions()) return $this->denied; | |
| 113 | +        if (! $this->checkRestrictions()) { | |
| 114 | + return $this->denied; | |
| 115 | + } | |
| 112 | 116 | |
| 113 | - if ($this->hasModel($model, $relation)) return $this->allowed; | |
| 117 | +        if ($this->hasModel($model, $relation)) { | |
| 118 | + return $this->allowed; | |
| 119 | + } | |
| 114 | 120 | |
| 115 | 121 | return $this->hasLevel($min) ? $this->allowed : $this->denied; | 
| 116 | 122 | } | 
| @@ -128,7 +134,9 @@ discard block | ||
| 128 | 134 | |
| 129 | 135 | // First we need to check restritions for given Role | 
| 130 | 136 | // to detect special Location, IP, Hours conditions. | 
| 131 | - if (! $this->checkRestrictions()) return $this->denied; | |
| 137 | +        if (! $this->checkRestrictions()) { | |
| 138 | + return $this->denied; | |
| 139 | + } | |
| 132 | 140 | |
| 133 | 141 | return $this->hasLevel($min) ? $this->allowed : $this->denied; | 
| 134 | 142 | } | 
| @@ -147,7 +155,9 @@ discard block | ||
| 147 | 155 | |
| 148 | 156 | // First we need to check restritions for given Role | 
| 149 | 157 | // to detect special Location, IP, Hours conditions. | 
| 150 | - if (! $this->checkRestrictions()) return $this->denied; | |
| 158 | +        if (! $this->checkRestrictions()) { | |
| 159 | + return $this->denied; | |
| 160 | + } | |
| 151 | 161 | |
| 152 | 162 | return $this->isOwner($model, $foreign) ? $this->allowed : $this->denied; | 
| 153 | 163 | } | 
| @@ -167,9 +177,13 @@ discard block | ||
| 167 | 177 | |
| 168 | 178 | // First we need to check restritions for given Role | 
| 169 | 179 | // to detect special Location, IP, Hours conditions. | 
| 170 | - if (! $this->checkRestrictions()) return $this->denied; | |
| 180 | +        if (! $this->checkRestrictions()) { | |
| 181 | + return $this->denied; | |
| 182 | + } | |
| 171 | 183 | |
| 172 | - if ($this->isOwner($model, $foreign)) return $this->allowed; | |
| 184 | +        if ($this->isOwner($model, $foreign)) { | |
| 185 | + return $this->allowed; | |
| 186 | + } | |
| 173 | 187 | |
| 174 | 188 | return $this->hasLevel($min) ? $this->allowed : $this->denied; | 
| 175 | 189 | } | 
| @@ -202,7 +216,9 @@ discard block | ||
| 202 | 216 | |
| 203 | 217 | // First we need to check restritions for given Role | 
| 204 | 218 | // to detect special Location, IP, Hours conditions. | 
| 205 | - if (! $this->checkRestrictions()) return $this->denied; | |
| 219 | +        if (! $this->checkRestrictions()) { | |
| 220 | + return $this->denied; | |
| 221 | + } | |
| 206 | 222 | |
| 207 | 223 | return $this->isSharing($model, $modelRelation, $relation) ? | 
| 208 | 224 | $this->allowed : $this->denied; | 
| @@ -13,7 +13,7 @@ | ||
| 13 | 13 | */ | 
| 14 | 14 | public function up() | 
| 15 | 15 |      { | 
| 16 | -        Schema::create('priv_roles', function (Blueprint $table) { | |
| 16 | +        Schema::create('priv_roles', function(Blueprint $table) { | |
| 17 | 17 |              $table->increments('id'); | 
| 18 | 18 |              $table->string('name')->unique(); | 
| 19 | 19 |              $table->unsignedTinyInteger('level')->default(0); // Visitor,Employee,Manager,Director | 
| @@ -17,7 +17,7 @@ | ||
| 17 | 17 |      { | 
| 18 | 18 | $config = Manager::getAuthorizableMigration(); | 
| 19 | 19 | |
| 20 | -        Schema::create('priv_auth_role', function (Blueprint $table) use ($config) { | |
| 20 | +        Schema::create('priv_auth_role', function(Blueprint $table) use ($config) { | |
| 21 | 21 | // Depend on Authorizable table structure | 
| 22 | 22 | // package provides support for tree types | 
| 23 | 23 | // of primaryKey: integer, string & uuid. | 
| @@ -13,7 +13,7 @@ | ||
| 13 | 13 | */ | 
| 14 | 14 | public function up() | 
| 15 | 15 |      { | 
| 16 | -        Schema::create('priv_permissions', function (Blueprint $table) { | |
| 16 | +        Schema::create('priv_permissions', function(Blueprint $table) { | |
| 17 | 17 |              $table->increments('id'); | 
| 18 | 18 |              $table->morphs('grantable'); | 
| 19 | 19 |              $table->string('scope'); | 
| @@ -26,7 +26,7 @@ discard block | ||
| 26 | 26 |      { | 
| 27 | 27 | $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); | 
| 28 | 28 | |
| 29 | -        $this->publishes([__DIR__ .'/../config/privileges.php' => config_path('privileges.php')], 'config'); | |
| 29 | +        $this->publishes([__DIR__.'/../config/privileges.php' => config_path('privileges.php')], 'config'); | |
| 30 | 30 | |
| 31 | 31 |          $this->publishes([__DIR__.'/../database/migrations/' => database_path('migrations')], 'migrations'); | 
| 32 | 32 | } | 
| @@ -38,16 +38,16 @@ discard block | ||
| 38 | 38 | */ | 
| 39 | 39 | public function register() | 
| 40 | 40 |      { | 
| 41 | - $this->mergeConfigFrom(__DIR__ .'/../config/privileges.php', 'privileges'); | |
| 41 | + $this->mergeConfigFrom(__DIR__.'/../config/privileges.php', 'privileges'); | |
| 42 | 42 | |
| 43 | -        $this->app->singleton('mrluke-privileges-detector', function ($app) { | |
| 43 | +        $this->app->singleton('mrluke-privileges-detector', function($app) { | |
| 44 | 44 | |
| 45 | 45 |              $manager = $app->make('mrluke-privileges-manager'); | 
| 46 | 46 | |
| 47 | 47 | return new \Mrluke\Privileges\Detector($manager); | 
| 48 | 48 | }); | 
| 49 | 49 | |
| 50 | -        $this->app->singleton('mrluke-privileges-manager', function ($app) { | |
| 50 | +        $this->app->singleton('mrluke-privileges-manager', function($app) { | |
| 51 | 51 | |
| 52 | 52 | $schema = \Mrluke\Configuration\Schema::createFromFile( | 
| 53 | 53 | __DIR__.'/../config/schema.json', | 
| @@ -170,7 +170,7 @@ discard block | ||
| 170 | 170 | public function detectScope(string $model) | 
| 171 | 171 |      { | 
| 172 | 172 | return $this->config->get( | 
| 173 | - 'mapping.' . $model, | |
| 173 | + 'mapping.'.$model, | |
| 174 | 174 |              $this->config->get('mapping_default') | 
| 175 | 175 | ); | 
| 176 | 176 | } | 
| @@ -233,7 +233,7 @@ discard block | ||
| 233 | 233 |          if (':*' === substr($scope, -2)) { | 
| 234 | 234 | $scope = substr($scope, 0, -2); | 
| 235 | 235 | |
| 236 | -            return $subject->permissions->sortbyDesc('level')->first(function ($perm) use ($scope) { | |
| 236 | +            return $subject->permissions->sortbyDesc('level')->first(function($perm) use ($scope) { | |
| 237 | 237 |                  return preg_match("/^(${scope}$|${scope}:)/", $perm['scope']); | 
| 238 | 238 | }); | 
| 239 | 239 | } | 
| @@ -249,11 +249,11 @@ discard block | ||
| 249 | 249 | */ | 
| 250 | 250 | public static function getScopeRestrictions($subject, string $scope): array | 
| 251 | 251 |      { | 
| 252 | -        $scopes = $subject->roles->flatMap(function ($role) use ($scope) { | |
| 252 | +        $scopes = $subject->roles->flatMap(function($role) use ($scope) { | |
| 253 | 253 |              return preg_grep("/^${scope}:/", array_column($role->permissions->toArray(), 'scope')); | 
| 254 | 254 | })->toArray(); | 
| 255 | 255 | |
| 256 | -        return array_map(function ($scope) { | |
| 256 | +        return array_map(function($scope) { | |
| 257 | 257 |              return explode(':', $scope)[1]; | 
| 258 | 258 | }, $scopes); | 
| 259 | 259 | } |