Completed
Pull Request — master (#21)
by Fèvre
04:45 queued 02:13
created

Role   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A boot() 0 9 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
        'level'
22
    ];
23
24
    /**
25
     * The "booting" method of the model.
26
     *
27
     * @return void
28
     */
29
    protected static function boot()
30
    {
31
        parent::boot();
32
33
        // Generated the slug before updating.
34
        static::updating(function ($model) {
35
            $model->setSlugAttribute($model->name);
36
        });
37
    }
38
}
39