From d1974e1cb2d0c5bb3cde64e939361cfa4845ec2c Mon Sep 17 00:00:00 2001 From: Sean Fraser Date: Sat, 12 Nov 2016 21:59:20 -0500 Subject: [PATCH] fixed getOrderValueForTags escaping raw column names --- src/Mediable.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Mediable.php b/src/Mediable.php index a84fa6c..35885cf 100644 --- a/src/Mediable.php +++ b/src/Mediable.php @@ -450,9 +450,11 @@ protected function handleMediableDeletion() */ private function getOrderValueForTags($tags) { + $q = $this->media()->newPivotStatement(); $tags = (array) $tags; - $result = $this->media()->newPivotStatement() - ->selectRaw('`tag`, max(`order`) as aggregate') + $grammar = $q->getConnection()->getQueryGrammar(); + + $result = $q->selectRaw($grammar->wrap('tag').', max('.$grammar->wrap('order').') as aggregate') ->where('mediable_type', $this->getMorphClass()) ->where('mediable_id', $this->getKey()) ->whereIn('tag', $tags)