Ensure Laravel feature is supported before using

This commit is contained in:
Toby Zerner 2021-07-22 12:28:02 +09:30
parent cd9a43de7e
commit dc8ec9ee1d
1 changed files with 2 additions and 2 deletions

View File

@ -215,10 +215,10 @@ class EloquentAdapter implements AdapterInterface
$query = $relation->getQuery(); $query = $relation->getQuery();
if (is_array($scope)) { if (is_array($scope)) {
// Requires Laravel 8.15+
foreach ($scope as $v) { foreach ($scope as $v) {
// Requires Laravel 8.15+
$adapter = $v['resource']->getAdapter(); $adapter = $v['resource']->getAdapter();
if ($adapter instanceof self) { if ($adapter instanceof self && method_exists($relation, 'constrain')) {
$relation->constrain([ $relation->constrain([
get_class($adapter->newModel()) => $v['scope'] get_class($adapter->newModel()) => $v['scope']
]); ]);