Skip to content

Commit

Permalink
Prevent MissingAttributeException for guard_name
Browse files Browse the repository at this point in the history
When new Laravel feature `Model::preventAccessingMissingAttributes()` is enabled you may get a `MissingAttributeException` for `guard_name`. This change uses `getAttributeValue()` to prevent the exception. Fixes #2215
  • Loading branch information
ejunker authored Oct 17, 2022
1 parent cf0f55b commit ecf27c5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Guard.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static function getNames($model): Collection
if (\method_exists($model, 'guardName')) {
$guardName = $model->guardName();
} else {
$guardName = $model->guard_name ?? null;
$guardName = $model->getAttributeValue('guard_name');
}
}

Expand Down

0 comments on commit ecf27c5

Please sign in to comment.