@@ -40,7 +40,7 @@ |
||
40 | 40 | |
41 | 41 | private function isAuthorizedRequestFor(Request $request): Closure |
42 | 42 | { |
43 | - return function (array $grantables) use ($request): bool { |
|
43 | + return function(array $grantables) use ($request): bool { |
|
44 | 44 | $user = $request->user(); |
45 | 45 | return $user instanceof GrantableOwner && $this->authorized($user, $grantables); |
46 | 46 | }; |
@@ -28,7 +28,7 @@ |
||
28 | 28 | |
29 | 29 | private function revokeTo(BelongsToMany $authorizations): Closure |
30 | 30 | { |
31 | - return function (Grantable $grantable) use ($authorizations): void { |
|
31 | + return function(Grantable $grantable) use ($authorizations): void { |
|
32 | 32 | $saved = $this->isSuccessful($authorizations->detach($this->castToModel($grantable))); |
33 | 33 | $this->throwErrorIfNotSaved($saved, $grantable); |
34 | 34 | }; |
@@ -31,21 +31,21 @@ discard block |
||
31 | 31 | |
32 | 32 | public function permissions(PermissionsOwner $owner, Collection $permissions): void |
33 | 33 | { |
34 | - $permissions->each(function (PermissionContract $permission) use ($owner) { |
|
34 | + $permissions->each(function(PermissionContract $permission) use ($owner) { |
|
35 | 35 | $this->permission($owner, $permission); |
36 | 36 | }); |
37 | 37 | } |
38 | 38 | |
39 | 39 | public function roles(RolesOwner $owner, Collection $roles): void |
40 | 40 | { |
41 | - $roles->each(function (RoleContract $role) use ($owner) { |
|
41 | + $roles->each(function(RoleContract $role) use ($owner) { |
|
42 | 42 | $this->role($owner, $role); |
43 | 43 | }); |
44 | 44 | } |
45 | 45 | |
46 | 46 | protected function castToModel(Grantable $grantable): Model |
47 | 47 | { |
48 | - if (! $grantable instanceof Model) { |
|
48 | + if ( ! $grantable instanceof Model) { |
|
49 | 49 | throw GrantableIsNotValidModelException::make($grantable); |
50 | 50 | } |
51 | 51 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | protected function throwErrorIfNotSaved(bool $saved, Grantable $grantable): void |
56 | 56 | { |
57 | - if (! $saved) { |
|
57 | + if ( ! $saved) { |
|
58 | 58 | throw new AuthorizationNotGrantedException($grantable); |
59 | 59 | } |
60 | 60 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | |
29 | 29 | protected function grantTo(BelongsToMany $authorizations): Closure |
30 | 30 | { |
31 | - return function (Grantable $grantable) use ($authorizations): void { |
|
31 | + return function(Grantable $grantable) use ($authorizations): void { |
|
32 | 32 | $saved = ! is_null($authorizations->save($this->castToModel($grantable))); |
33 | 33 | $this->throwErrorIfNotSaved($saved, $grantable); |
34 | 34 | }; |
@@ -12,14 +12,14 @@ |
||
12 | 12 | { |
13 | 13 | protected function has(Builder $repository): Closure |
14 | 14 | { |
15 | - return function (array $grantableNames) use ($repository): bool { |
|
15 | + return function(array $grantableNames) use ($repository): bool { |
|
16 | 16 | return ($this->same($grantableNames)($repository))->exists(); |
17 | 17 | }; |
18 | 18 | } |
19 | 19 | |
20 | 20 | protected function same(array $grantableNames): Closure |
21 | 21 | { |
22 | - return function (Builder $repository) use ($grantableNames): Builder { |
|
22 | + return function(Builder $repository) use ($grantableNames): Builder { |
|
23 | 23 | return $repository->limit(1)->whereIn('secret_name', $grantableNames); |
24 | 24 | }; |
25 | 25 | } |
@@ -106,8 +106,8 @@ |
||
106 | 106 | |
107 | 107 | private function filterOnly(string $abstract): Closure |
108 | 108 | { |
109 | - return function (array $grantables) use ($abstract): Collection { |
|
110 | - return collect($grantables)->filter(function (Grantable $grantable) use ($abstract) { |
|
109 | + return function(array $grantables) use ($abstract): Collection { |
|
110 | + return collect($grantables)->filter(function(Grantable $grantable) use ($abstract) { |
|
111 | 111 | return $grantable instanceof $abstract; |
112 | 112 | }); |
113 | 113 | }; |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | Schema::create(Config::userRoleTableName(), $this->getAuthorizationsStructure(Config::roleTableName())); |
15 | 15 | Schema::create(Config::userPermissionTableName(), $this->getAuthorizationsStructure(Config::permissionTableName())); |
16 | 16 | |
17 | - Schema::create(Config::rolePermissionTableName(), function (Blueprint $table): void { |
|
17 | + Schema::create(Config::rolePermissionTableName(), function(Blueprint $table): void { |
|
18 | 18 | $table->unsignedInteger('role_id'); |
19 | 19 | $table->foreign('role_id')->references('id')->on(Config::roleTableName()); |
20 | 20 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | private function getGrantableStructure(): Closure |
40 | 40 | { |
41 | - return function (Blueprint $table): void { |
|
41 | + return function(Blueprint $table): void { |
|
42 | 42 | $table->increments('id'); |
43 | 43 | $table->string('secret_name', 60)->unique(); |
44 | 44 | $table->string('display_name', 60); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | private function getAuthorizationsStructure($tableName): Closure |
51 | 51 | { |
52 | - return function (Blueprint $table) use ($tableName): void { |
|
52 | + return function(Blueprint $table) use ($tableName): void { |
|
53 | 53 | $table->increments('id'); |
54 | 54 | |
55 | 55 | $table->unsignedInteger('authorizable_id'); |