Completed
Push — master ( 58fb5e...df6768 )
by Fèvre
14s
created

Role   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 37
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A boot() 0 14 1
1
<?php
2
namespace Xetaravel\Models;
3
4
use Ultraware\Roles\Contracts\RoleHasRelations as RoleHasRelationsContract;
5
use Ultraware\Roles\Traits\RoleHasRelations;
6
use Ultraware\Roles\Traits\Slugable;
7
8
class Role extends Model implements RoleHasRelationsContract
9
{
10
    use Slugable, RoleHasRelations;
11
12
    /**
13
     * The attributes that are mass assignable.
14
     *
15
     * @var array
16
     */
17
    protected $fillable = [
18
        'name',
19
        'slug',
20
        'description',
21
        'css',
22
        'level'
23
    ];
24
25
    /**
26
     * The "booting" method of the model.
27
     *
28
     * @return void
29
     */
30
    protected static function boot()
31
    {
32
        parent::boot();
33
34
        // Generated the slug before updating.
35
        static::updating(function ($model) {
36
            $model->setSlugAttribute($model->name);
37
        });
38
39
        // Generated the slug before creating.
40
        static::creating(function ($model) {
41
            $model->setSlugAttribute($model->name);
42
        });
43
    }
44
}
45