From 9fc11b2eacce79008e7901ebfa96d233f1366c16 Mon Sep 17 00:00:00 2001 From: f1nal Date: Tue, 14 Feb 2017 10:07:29 +0300 Subject: [PATCH] compatibility with laravel/lumen 5.4 --- src/SleepingOwl/WithJoin/WithJoinEloquentBuilder.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/SleepingOwl/WithJoin/WithJoinEloquentBuilder.php b/src/SleepingOwl/WithJoin/WithJoinEloquentBuilder.php index 15728ed..3b3047b 100644 --- a/src/SleepingOwl/WithJoin/WithJoinEloquentBuilder.php +++ b/src/SleepingOwl/WithJoin/WithJoinEloquentBuilder.php @@ -62,7 +62,7 @@ protected function isNestedRelation($relation) */ protected function addNestedRelations($name, Relation $relation) { - $nestedRelations = $this->nestedRelations($name); + $nestedRelations = $getOtherKey = method_exists($this, 'nestedRelations') ? $this->nestedRelations($name) : $this->relationsNestedUnder($name); if (count($nestedRelations) <= 0) return; $class = $relation->getRelated(); @@ -82,6 +82,7 @@ protected function addNestedRelations($name, Relation $relation) protected function addJoinToQuery($joinTableAlias, $currentTableAlias, Relation $relation, $columnsPrefix = '') { $joinTableName = $relation->getRelated()->getTable(); + $getOtherKey = !method_exists($relation, 'getOtherKey') ? $relation->getOwnerKey() : $relation->getOtherKey(); $joinTable = implode(' as ', [ $joinTableName, @@ -89,7 +90,7 @@ protected function addJoinToQuery($joinTableAlias, $currentTableAlias, Relation ]); $joinLeftCondition = implode('.', [ $joinTableAlias, - $relation->getOtherKey() + $getOtherKey ]); $joinRightCondition = implode('.', [ $currentTableAlias,