Conditions | 1 |
Paths | 1 |
Total Lines | 14 |
Code Lines | 6 |
Lines | 14 |
Ratio | 100 % |
Changes | 0 |
1 | <?php |
||
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 |
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.