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

Role::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
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