File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,7 @@ public function search(Builder $builder)
101101 return $ this ->performSearch ($ builder , array_filter ([
102102 'filters ' => $ this ->filters ($ builder ),
103103 'limit ' => $ builder ->limit ,
104+ 'sort ' => $ this ->buildSortFromOrderByClauses ($ builder ),
104105 ]));
105106 }
106107
@@ -185,6 +186,19 @@ protected function filters(Builder $builder)
185186 return $ filters ->values ()->implode (' AND ' );
186187 }
187188
189+ /**
190+ * Get the sort array for the query.
191+ *
192+ * @param \Laravel\Scout\Builder $builder
193+ * @return array
194+ */
195+ protected function buildSortFromOrderByClauses (Builder $ builder ): array
196+ {
197+ return collect ($ builder ->orders )->map (function (array $ order ) {
198+ return $ order ['column ' ].': ' .$ order ['direction ' ];
199+ })->toArray ();
200+ }
201+
188202 /**
189203 * Pluck and return the primary keys of the given results.
190204 *
You can’t perform that action at this time.
0 commit comments