Passed
Pull Request — master (#52)
by
unknown
06:32
created

Role   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 26
ccs 2
cts 4
cp 0.5
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A permissions() 0 3 1
A scopeGrantedRoles() 0 3 1
1
<?php
2
3
namespace App;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class Role extends Model
8
{
9
    protected $table = 'roles';
10
11
    protected $fillable = ['name', 'label'];
12
13
    /**
14
     * A role may be given various permissions.
15
     *
16
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
17
     */
18
    public function permissions()
19
    {
20
        return $this->belongsToMany(Permission::class);
0 ignored issues
show
Bug introduced by
The type App\Permission was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
    }
22
23
    /**
24
     * Grant the given permission to a role.
25
     *
26
     * @param $query
27
     * @param $userType
28
     * @return mixed
29
     */
30 1
    public function scopeGrantedRoles($query, $userType)
31
    {
32 1
        return $query->where('id', '>=', $userType);
33
    }
34
}