Skip to content

Commit 39876b3

Browse files
authored
Merge pull request #4743 from Laravel-Backpack/fix-single-morphs
add null checking for options when it's a string in a morphMap
2 parents 0175436 + 59c5de1 commit 39876b3

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/app/Library/CrudPanel/Traits/MorphRelationships.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,8 @@ private function getMorphTypeFieldWithOptions(array $morphTypeField, string $key
156156
if (! array_key_exists($key, $morphMap)) {
157157
throw new \Exception('Unknown morph type «'.$key.'», that name was not found in the morphMap.');
158158
}
159-
160159
// check if the key already exists
161-
if (array_key_exists($key, $morphTypeField['options'])) {
160+
if (array_key_exists($key, $morphTypeField['options'] ?? [])) {
162161
throw new \Exception('Duplicate entry for «'.$key.'» key, That string is already part of another morphOption. Current options: '.json_encode($morphTypeField['options']));
163162
}
164163
// use the provided label or capitalize the provided key.

0 commit comments

Comments
 (0)