From ce77c0f89e239f1303d27bda1bc42f9f3af0f990 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Sat, 28 Feb 2015 22:08:25 +1100 Subject: [PATCH] Return a query that includes pivot data for belongsToMany relations --- modules/backend/behaviors/RelationController.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/backend/behaviors/RelationController.php b/modules/backend/behaviors/RelationController.php index acb33e691..85153fe4a 100644 --- a/modules/backend/behaviors/RelationController.php +++ b/modules/backend/behaviors/RelationController.php @@ -969,6 +969,11 @@ class RelationController extends ControllerBehavior elseif ($this->model->exists) { $this->relationObject->addConstraints(); } + + if ($this->relationType == 'belongsToMany') { + $this->relationObject->setQuery($query->getQuery()); + return $this->relationObject; + } }); /*