Completed
Push — master ( bfbb50...8023d3 )
by Sherif
09:55
created

Permission   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 21
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A roles() 0 4 1
A boot() 0 5 1
1
<?php
2
3
namespace App\Modules\Permissions;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\SoftDeletes;
7
use App\Modules\Roles\Role;
8
use App\Modules\Permissions\ModelObservers\PermissionObserver;
9
10
class Permission extends Model
11
{
12
13
    use SoftDeletes;
14
    protected $table    = 'permissions';
15
    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
16
    protected $hidden   = ['deleted_at'];
17
    protected $guarded  = ['id'];
18
    protected $fillable = ['name', 'model'];
19
    
20
    public function roles()
21
    {
22
        return $this->belongsToMany(Role::class, 'permission_role', 'permission_id', 'role_id')->whereNull('permission_role.deleted_at')->withTimestamps();
23
    }
24
25
    public static function boot()
26
    {
27
        parent::boot();
28
        Permission::observe(PermissionObserver::class);
29
    }
30
}
31