Skip to content

Commit d1f0e90

Browse files
authored
Merge pull request #121 from Muetze42/development
fix: prevent errors on HasSlugTrait
2 parents e36f72b + 4378ce5 commit d1f0e90

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Traits/Models/HasSlugTrait.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public static function bootHasSlugTrait(): void
2525
{
2626
static::saving(function (Model $model) {
2727
foreach ((new static())->sluggable as $attribute) {
28-
if (in_array($attribute, (new static())->getFillable()) || ! is_null($model->{$attribute})) {
28+
/** @noinspection NotOptimalIfConditionsInspection */
29+
if ($model->hasAttribute($attribute) && ! is_null($model->{$attribute})) {
2930
$model->slug = Str::slug($model->{$attribute});
3031
}
3132
}

0 commit comments

Comments
 (0)