Issues (367)

app/Permissions/HasPermissionsTrait.php (1 issue)

Labels
Severity
1
<?php
2
3
4
namespace App\Permissions;
5
6
use App\Models\Security_group_user;
7
8
trait HasPermissionsTrait
9
{
10
    public function roles(){
11
        return $this->belongsToMany(Security_group_user::class,'security_group_users');
0 ignored issues
show
It seems like belongsToMany() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

11
        return $this->/** @scrutinizer ignore-call */ belongsToMany(Security_group_user::class,'security_group_users');
Loading history...
12
    }
13
14
15
    public function hasRole( ... $roles ) {
16
        foreach ($roles as $role) {
17
            if ($this->roles->contains('code', $role)) {
18
                return true;
19
            }
20
        }
21
        return false;
22
    }
23
24
25
}