Passed
Pull Request — master (#112)
by Ron
17:16
created

UserSettingsTrait   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 3
c 1
b 0
f 0
dl 0
loc 22
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A filterUserSettings() 0 20 1
1
<?php
2
3
namespace App\Traits;
4
5
use App\Models\User;
6
use App\Models\UserSetting;
7
use App\Models\UserRolePermissions;
8
9
trait UserSettingsTrait
10
{
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
        // dd($userSettings);
17
18
        //  TODO -> Finish this - Filter out any settings that the user is not allowed to adjust
19
        // foreach($userSettings as $key => $setting)
20
        // {
21
        //     $allowed = UserRolePermissions::where('role_id', $user->user_id)->where('perm_type_id', $setting->UserSettingType->perm_type_id)->first(); // ->allow;
22
23
        //     dd($allowed);
24
        //     if(!$allowed)
25
        //     {
26
        //         $userSettings->forget($key);
27
        //     }
28
        // }
29
30
        return $userSettings;
31
    }
32
}
33