From ecf27c5f0d62210a38f9edef59352ec872b1d241 Mon Sep 17 00:00:00 2001 From: Eric Junker Date: Mon, 17 Oct 2022 11:35:00 -0500 Subject: [PATCH] Prevent MissingAttributeException for guard_name 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 --- src/Guard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Guard.php b/src/Guard.php index 41d802c10..c0630392b 100644 --- a/src/Guard.php +++ b/src/Guard.php @@ -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'); } }