Passed
Push — dev6 ( d7b093...318218 )
by Ron
15:35
created

GatePolicy   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
c 4
b 0
f 0
dl 0
loc 15
ccs 2
cts 2
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A adminLink() 0 8 2
1
<?php
2
3
namespace App\Policies;
4
5
use App\Models\User;
6
use App\Models\UserRolePermissions;
7
use Illuminate\Auth\Access\HandlesAuthorization;
8
9
class GatePolicy
10
{
11
    use HandlesAuthorization;
12
13
    /**
14
     * Determine if the user is allowed to see the Administration navigation link
15
     */
16
    public function adminLink(User $user)
17
    {
18
        $userRole = UserRolePermissions::whereRoleId($user->role_id)->whereHas('UserRolePermissionTypes', function($q)
19
        {
20 24
            $q->whereIsAdminLink(1);
21
        })->whereAllow(1)->count();
22
23 24
        return $userRole == 0 ? false : true;
24
    }
25
}
26