Skip to content

Commit 59c5de1

Browse files
committed
add null checking for options
1 parent e6ac5c8 commit 59c5de1

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)