Skip to content

Commit de79385

Browse files
committed
[Fix #1] fix issue relationship with laravel medialibrary
1 parent af7b4d5 commit de79385

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/composer.lock
22
/vendor
33
/.phpunit.result.cache
4+
.idea

Eloquent/Metadata/ModelMetadata.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,11 @@ public function getRelations(Model $model): Collection
197197
->contains(fn ($relationMethod) => str_contains($code, '$this->'.$relationMethod.'('));
198198
})
199199
->map(function (\ReflectionMethod $method) use ($model) {
200-
$relation = $method->invoke($model);
200+
try {
201+
$relation = $method->invoke($model);
202+
}catch (\Exception $exception){
203+
return null;
204+
}
201205

202206
if (!$relation instanceof Relation) {
203207
return null;
@@ -287,4 +291,4 @@ private function columnIsUnique(string $column, array $indexes): bool
287291
fn ($index) => 1 === \count($index['columns']) && $index['columns'][0] === $column && $index['unique']
288292
);
289293
}
290-
}
294+
}

0 commit comments

Comments
 (0)