@@ -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 |
@@ -31,9 +31,9 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | public function percentage($settings, ActivityInstance $activityInstance, ModuleInstance $moduleInstance): int |
| 33 | 33 | { |
| 34 | - if($activityInstance->resource_type === 'group') { |
|
| 34 | + if ($activityInstance->resource_type === 'group') { |
|
| 35 | 35 | $group = $activityInstance->participant(); |
| 36 | - } else if($activityInstance->resource_type === 'role') { |
|
| 36 | + } else if ($activityInstance->resource_type === 'role') { |
|
| 37 | 37 | $group = $activityInstance->participant()->group(); |
| 38 | 38 | } else { |
| 39 | 39 | return collect(); |
@@ -42,15 +42,15 @@ discard block |
||
| 42 | 42 | $requiredPositions = $this->getRequiredPositions($settings, $group); |
| 43 | 43 | $remainingPositions = $this->rolesNeededtoFill($settings, $activityInstance, $moduleInstance); |
| 44 | 44 | |
| 45 | - if(count($requiredPositions) === 0) { |
|
| 45 | + if (count($requiredPositions) === 0) { |
|
| 46 | 46 | return 100; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $filled = count($requiredPositions) - count($remainingPositions); |
| 50 | 50 | |
| 51 | - $percentage = (int) round(($filled/count($requiredPositions)) * 100, 0); |
|
| 51 | + $percentage = (int) round(($filled / count($requiredPositions)) * 100, 0); |
|
| 52 | 52 | |
| 53 | - if($percentage > 100) { |
|
| 53 | + if ($percentage > 100) { |
|
| 54 | 54 | return 100; |
| 55 | 55 | } |
| 56 | 56 | return $percentage; |
@@ -58,9 +58,9 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | protected function rolesNeededtoFill($settings, ActivityInstance $activityInstance, ModuleInstance $moduleInstance) |
| 60 | 60 | { |
| 61 | - if($activityInstance->resource_type === 'group') { |
|
| 61 | + if ($activityInstance->resource_type === 'group') { |
|
| 62 | 62 | $group = $activityInstance->participant(); |
| 63 | - } else if($activityInstance->resource_type === 'role') { |
|
| 63 | + } else if ($activityInstance->resource_type === 'role') { |
|
| 64 | 64 | $group = $activityInstance->participant()->group(); |
| 65 | 65 | } else { |
| 66 | 66 | return collect(); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | $requiredPositions = $this->getRequiredPositions($settings, $group); |
| 70 | 70 | $roles = $group->roles(); |
| 71 | 71 | $logicGroupId = $moduleInstance->setting('logic_group', null); |
| 72 | - if($logicGroupId !== null) { |
|
| 72 | + if ($logicGroupId !== null) { |
|
| 73 | 73 | $logic = app(LogicRepository::class)->getById($logicGroupId); |
| 74 | 74 | |
| 75 | 75 | $roles = $roles->filter(function(\BristolSU\ControlDB\Contracts\Models\Role $role) use ($logic) { |
@@ -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; |
@@ -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 | } |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | public function rules() |
| 13 | 13 | { |
| 14 | 14 | return [ |
| 15 | - 'position_id' => ['required', app(PositionIsAllowed::class), app(PositionCanBeUsed::class)], |
|
| 15 | + 'position_id' => ['required', app(PositionIsAllowed::class), app(PositionCanBeUsed::class)], |
|
| 16 | 16 | 'role_name' => ['required', 'string', 'max:255', 'min:3'], |
| 17 | 17 | 'email' => ['nullable', 'sometimes', 'email'] |
| 18 | 18 | ]; |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | $roles = $role->allThroughGroup( |
| 35 | 35 | $authentication->getGroup() |
| 36 | 36 | ); |
| 37 | - if(settings('logic_group', null) !== null) { |
|
| 37 | + if (settings('logic_group', null) !== null) { |
|
| 38 | 38 | $logic = $logicRepository->getById(settings('logic_group')); |
| 39 | 39 | |
| 40 | 40 | $roles = $roles->filter(function(\BristolSU\ControlDB\Contracts\Models\Role $role) use ($logic) { |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | public function getSettings(Group $group) |
| 36 | 36 | { |
| 37 | - if(Cache::has($this->getCacheKey($group))) { |
|
| 37 | + if (Cache::has($this->getCacheKey($group))) { |
|
| 38 | 38 | return Cache::get($this->getCacheKey($group)); |
| 39 | 39 | } |
| 40 | 40 | $settings = settings('position_settings', []); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | return false; |
| 54 | 54 | } |
| 55 | 55 | $logic = $this->logicRepository->getById($setting['logic_id']); |
| 56 | - $groups = collect($this->logicAudience->groupAudience($logic))->map(function (Group $group) { |
|
| 56 | + $groups = collect($this->logicAudience->groupAudience($logic))->map(function(Group $group) { |
|
| 57 | 57 | return $group->id(); |
| 58 | 58 | }); |
| 59 | 59 | return $groups->contains($group->id()); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | protected function getCacheKey(Group $group) |
| 63 | 63 | { |
| 64 | - return PositionSettingRetrieval::class . '.' . $group->id(); |
|
| 64 | + return PositionSettingRetrieval::class.'.'.$group->id(); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | public function parse($setting) |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | public function getSettings(Group $group, array $settings) |
| 36 | 36 | { |
| 37 | - if(Cache::has($this->getCacheKey($group))) { |
|
| 37 | + if (Cache::has($this->getCacheKey($group))) { |
|
| 38 | 38 | return Cache::get($this->getCacheKey($group)); |
| 39 | 39 | } |
| 40 | 40 | foreach ($settings as $setting) { |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | protected function getCacheKey(Group $group) |
| 50 | 50 | { |
| 51 | - return RequiredSettingRetrieval::class . '.' . $group->id(); |
|
| 51 | + return RequiredSettingRetrieval::class.'.'.$group->id(); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | protected function groupIsForSetting(Group $group, array $setting): bool |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | return false; |
| 58 | 58 | } |
| 59 | 59 | $logic = $this->logicRepository->getById($setting['logic_id']); |
| 60 | - $groups = collect($this->logicAudience->groupAudience($logic))->map(function (Group $group) { |
|
| 60 | + $groups = collect($this->logicAudience->groupAudience($logic))->map(function(Group $group) { |
|
| 61 | 61 | return $group->id(); |
| 62 | 62 | }); |
| 63 | 63 | return $groups->contains($group->id()); |