Completed
Pull Request — master (#22)
by Fèvre
05:46 queued 02:55
created

Permission::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 6

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
dl 14
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
namespace Xetaravel\Models;
3
4
use Ultraware\Roles\Contracts\PermissionHasRelations as PermissionHasRelationsContract;
5
use Ultraware\Roles\Traits\PermissionHasRelations;
6
use Ultraware\Roles\Traits\Slugable;
7
8 View Code Duplication
class Permission extends Model implements PermissionHasRelationsContract
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    use Slugable, PermissionHasRelations;
11
12
    /**
13
     * The attributes that are mass assignable.
14
     *
15
     * @var array
16
     */
17
    protected $fillable = [
18
        'name',
19
        'slug',
20
        'description',
21
        'model'
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
        // Generated the slug before creating.
39
        static::creating(function ($model) {
40
            $model->setSlugAttribute($model->name);
41
        });
42
    }
43
}
44