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

Permission::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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