Conditions | 4 |
Paths | 4 |
Total Lines | 20 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | protected function filterUserSettings(User $user) |
||
12 | { |
||
13 | // Pull the user settings |
||
14 | $userSettings = UserSetting::where('user_id', $user->user_id)->with('UserSettingType')->get(); |
||
15 | |||
16 | foreach($userSettings as $key => $setting) |
||
17 | { |
||
18 | // Determine if this setting is linked to a permission feature (i.e. should not be displayed if the user cannot access the feature) |
||
19 | if(!is_null($setting->UserSettingType->perm_type_id)) |
||
20 | { |
||
21 | $allowed = UserRolePermissions::where('role_id', $user->role_id)->where('perm_type_id', $setting->UserSettingType->perm_type_id)->first(); |
||
22 | |||
23 | if(!$allowed->allow) |
||
24 | { |
||
25 | $userSettings->forget($key); |
||
26 | } |
||
27 | } |
||
28 | } |
||
29 | |||
30 | return $userSettings; |
||
31 | } |
||
33 |