@@ -22,9 +22,9 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | public function isComplete($settings, ActivityInstance $activityInstance, ModuleInstance $moduleInstance): bool |
| 24 | 24 | { |
| 25 | - $remainingRoles = $this->rolesNeededtoFill($settings, $activityInstance, $moduleInstance); |
|
| 25 | + $remainingRoles = $this->rolesNeededtoFill($settings, $activityInstance, $moduleInstance); |
|
| 26 | 26 | |
| 27 | - return count($remainingRoles) === 0; |
|
| 27 | + return count($remainingRoles) === 0; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | public function percentage($settings, ActivityInstance $activityInstance, ModuleInstance $moduleInstance): int |
@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | public function percentage($settings, ActivityInstance $activityInstance, ModuleInstance $moduleInstance): int |
| 31 | 31 | { |
| 32 | - if($activityInstance->resource_type === 'group') { |
|
| 32 | + if ($activityInstance->resource_type === 'group') { |
|
| 33 | 33 | $group = $activityInstance->participant(); |
| 34 | - } else if($activityInstance->resource_type === 'role') { |
|
| 34 | + } else if ($activityInstance->resource_type === 'role') { |
|
| 35 | 35 | $group = $activityInstance->participant()->group(); |
| 36 | 36 | } else { |
| 37 | 37 | return collect(); |
@@ -40,15 +40,15 @@ discard block |
||
| 40 | 40 | $requiredPositions = $this->getRequiredPositions($settings, $group); |
| 41 | 41 | $remainingPositions = $this->rolesNeededtoFill($settings, $activityInstance, $moduleInstance); |
| 42 | 42 | |
| 43 | - if(count($requiredPositions) === 0) { |
|
| 43 | + if (count($requiredPositions) === 0) { |
|
| 44 | 44 | return 100; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | $filled = count($requiredPositions) - count($remainingPositions); |
| 48 | 48 | |
| 49 | - $percentage = (int) round(($filled/count($requiredPositions)) * 100, 0); |
|
| 49 | + $percentage = (int) round(($filled / count($requiredPositions)) * 100, 0); |
|
| 50 | 50 | |
| 51 | - if($percentage > 100) { |
|
| 51 | + if ($percentage > 100) { |
|
| 52 | 52 | return 100; |
| 53 | 53 | } |
| 54 | 54 | return $percentage; |
@@ -56,9 +56,9 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | protected function rolesNeededtoFill($settings, ActivityInstance $activityInstance, ModuleInstance $moduleInstance) |
| 58 | 58 | { |
| 59 | - if($activityInstance->resource_type === 'group') { |
|
| 59 | + if ($activityInstance->resource_type === 'group') { |
|
| 60 | 60 | $group = $activityInstance->participant(); |
| 61 | - } else if($activityInstance->resource_type === 'role') { |
|
| 61 | + } else if ($activityInstance->resource_type === 'role') { |
|
| 62 | 62 | $group = $activityInstance->participant()->group(); |
| 63 | 63 | } else { |
| 64 | 64 | return collect(); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | $requiredPositions = $this->getRequiredPositions($settings, $group); |
| 68 | 68 | $roles = $group->roles(); |
| 69 | 69 | $logicGroupId = $moduleInstance->setting('logic_group', null); |
| 70 | - if($logicGroupId !== null) { |
|
| 70 | + if ($logicGroupId !== null) { |
|
| 71 | 71 | $logic = app(LogicRepository::class)->getById($logicGroupId); |
| 72 | 72 | $rolesInLogic = app(LogicAudience::class)->roleAudience($logic)->map(function(\BristolSU\ControlDB\Contracts\Models\Role $role) { |
| 73 | 73 | return $role->id(); |
@@ -146,15 +146,15 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | private function getRequiredPositions(array $settings, Group $group) |
| 148 | 148 | { |
| 149 | - foreach($settings['required'] as $setting) { |
|
| 149 | + foreach ($settings['required'] as $setting) { |
|
| 150 | 150 | if (!array_key_exists('logic_id', $setting)) { |
| 151 | 151 | continue; |
| 152 | 152 | } |
| 153 | 153 | $logic = app(LogicRepository::class)->getById($setting['logic_id']); |
| 154 | - $groups = collect(app(LogicAudience::class)->groupAudience($logic))->map(function (Group $group) { |
|
| 154 | + $groups = collect(app(LogicAudience::class)->groupAudience($logic))->map(function(Group $group) { |
|
| 155 | 155 | return $group->id(); |
| 156 | 156 | }); |
| 157 | - if($groups->contains($group->id())) { |
|
| 157 | + if ($groups->contains($group->id())) { |
|
| 158 | 158 | return $setting['required']; |
| 159 | 159 | } |
| 160 | 160 | } |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | return false; |
| 49 | 49 | } |
| 50 | 50 | $logic = $this->logicRepository->getById($setting['logic_id']); |
| 51 | - $groups = collect($this->logicAudience->groupAudience($logic))->map(function (Group $group) { |
|
| 51 | + $groups = collect($this->logicAudience->groupAudience($logic))->map(function(Group $group) { |
|
| 52 | 52 | return $group->id(); |
| 53 | 53 | }); |
| 54 | 54 | return $groups->contains($group->id()); |
@@ -98,7 +98,7 @@ |
||
| 98 | 98 | |
| 99 | 99 | public function baseDirectory() |
| 100 | 100 | { |
| 101 | - return __DIR__ . '/..'; |
|
| 101 | + return __DIR__.'/..'; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | public function boot() |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | } catch (\Exception $e) { |
| 41 | 41 | return false; |
| 42 | 42 | } |
| 43 | - if(in_array($value, $settings['only_one_role'])) { |
|
| 43 | + if (in_array($value, $settings['only_one_role'])) { |
|
| 44 | 44 | $roles = $this->roleRepository->allThroughGroup($this->group()); |
| 45 | 45 | return $roles->filter(function(\BristolSU\ControlDB\Contracts\Models\Role $role) use ($value) { |
| 46 | 46 | return $role->positionId() === (int) $value; |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | } catch (\Exception $e) { |
| 48 | 48 | return false; |
| 49 | 49 | } |
| 50 | - if(in_array($value, $settings['only_one_user'])) { |
|
| 50 | + if (in_array($value, $settings['only_one_user'])) { |
|
| 51 | 51 | return $this->roleRepository->getById($value)->users()->count() === 0; |
| 52 | 52 | } |
| 53 | 53 | return true; |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | $authentication->getGroup() |
| 28 | 28 | ); |
| 29 | 29 | |
| 30 | - if(settings('logic_group', null) !== null) { |
|
| 30 | + if (settings('logic_group', null) !== null) { |
|
| 31 | 31 | $logic = $logicRepository->getById(settings('logic_group')); |
| 32 | 32 | $rolesInLogic = $logicAudience->roleAudience($logic)->map(function(\BristolSU\ControlDB\Contracts\Models\Role $role) { |
| 33 | 33 | return $role->id(); |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | public function authorize($ability, $arguments = []) |
| 18 | 18 | { |
| 19 | 19 | return $this->baseAuthorize( |
| 20 | - 'assign-roles.' . $ability, |
|
| 20 | + 'assign-roles.'.$ability, |
|
| 21 | 21 | $arguments |
| 22 | 22 | ); |
| 23 | 23 | } |