Skip to content

Commit 6d8b498

Browse files
committed
check for class existence before checking strings
1 parent ac723f4 commit 6d8b498

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,14 @@ private function modelMethodIsRelationship($model, $method)
342342

343343
if ($returnType) {
344344
$returnType = $returnType->getName();
345+
346+
// this check is to make sure we don't autoload the class when checking strings instead of objects.
347+
// the third parameter of is_a() allow us to check strings, but it also autoloads the class
348+
// in case it does not exists. The classes we want to check against EXIST.
349+
if(!class_exists($returnType, false)) {
350+
return false;
351+
}
352+
// the above check
345353
if (is_a($returnType, 'Illuminate\Database\Eloquent\Casts\Attribute', true)) {
346354
return false;
347355
}

0 commit comments

Comments
 (0)