@@ -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; |
@@ -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 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public static function getScopeRestrictions($subject, string $scope, int $level = null): array |
| 23 | 23 | { |
| 24 | - $scopes = $subject->roles->flatMap(function ($role) use ($scope, $level) { |
|
| 24 | + $scopes = $subject->roles->flatMap(function($role) use ($scope, $level) { |
|
| 25 | 25 | if ($level) { |
| 26 | 26 | $permissions = $role->permissions->where('level', $level); |
| 27 | 27 | } else { |
@@ -31,8 +31,8 @@ discard block |
||
| 31 | 31 | return preg_grep("/^${scope}:/", array_column($permissions->toArray(), 'scope')); |
| 32 | 32 | })->toArray(); |
| 33 | 33 | |
| 34 | - return array_map(function ($val) use ($scope) { |
|
| 35 | - return str_replace($scope . ':', '', $val); |
|
| 34 | + return array_map(function($val) use ($scope) { |
|
| 35 | + return str_replace($scope.':', '', $val); |
|
| 36 | 36 | }, $scopes); |
| 37 | 37 | } |
| 38 | 38 | } |