Completed
Push — master ( 876e58...7fc0d0 )
by Arjay
18:23 queued 04:39
created

Role   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 42
rs 10
c 0
b 0
f 0
ccs 0
cts 5
cp 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 12 1
A users() 0 5 1
1
<?php
2
3
namespace Yajra\Acl\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Yajra\Acl\Traits\HasPermission;
7
8
/**
9
 * @property \Yajra\Acl\Models\Permission permissions
10
 * @property bool system
11
 */
12
class Role extends Model
13
{
14
    use HasPermission;
15
16
    /**
17
     * The database table used by the model.
18
     *
19
     * @var string
20
     */
21
    protected $table = 'roles';
22
23
    /**
24
     * Fillable fields.
25
     *
26
     * @var array
27
     */
28
    protected $fillable = ['name', 'slug', 'description', 'system'];
29
30
    protected static function boot()
31
    {
32
        parent::boot();
33
34
        static::saved(function () {
35
            app('cache.store')->forget('permissions.policies');
36
        });
37
38
        static::deleted(function () {
39
            app('cache.store')->forget('permissions.policies');
40
        });
41
    }
42
43
    /**
44
     * Roles can belong to many users.
45
     *
46
     * @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Relations\BelongsToMany
47
     */
48
    public function users()
49
    {
50
        return $this->belongsToMany(config('acl.user', config('auth.providers.users.model')))
51
                    ->withTimestamps();
52
    }
53
}
54