Test Failed
Push — dev6 ( 033ddc...06d260 )
by Ron
20:10
created

AllowTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
c 1
b 0
f 0
dl 0
loc 15
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A checkPermission() 0 13 2
1
<?php
2
3
namespace App\Traits;
4
5
use App\Models\User;
6
use App\Models\UserRolePermissions;
7
8
/**
9
 *  AllowTrait only has one function to check permission for the policies
10
 */
11
trait AllowTrait
12
{
13
    protected function checkPermission(User $user, $description)
14
    {
15
        $allowed = UserRolePermissions::whereRoleId($user->role_id)->whereHas('UserRolePermissionTypes', function($q) use ($description)
16
        {
17
            $q->where('description', $description);
18
        })->first();
19
20
        if($allowed)
21
        {
22
            return $allowed->allow;
23
        }
24
25
        return false;
26
    }
27
}
28