File tree 2 files changed +14
-3
lines changed
2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -130,7 +130,7 @@ protected function parseJoinSorts(Collection $sorts)
130
130
131
131
foreach ($ sorts as $ sortF => $ sortD ) {
132
132
[$ with , $ key ] = explode ('. ' , $ sortF );
133
- $ relation = self ::$ model ->{$ with }();
133
+ $ relation = self ::$ model ->{Helpers:: camel ( $ with) }();
134
134
$ type = class_basename (get_class ($ relation ));
135
135
136
136
if ($ type === 'HasOne ' ) {
@@ -143,10 +143,15 @@ protected function parseJoinSorts(Collection $sorts)
143
143
continue ;
144
144
}
145
145
146
+ $ withConnection = $ relation ->getRelated ()->getConnection ()->getDatabaseName ();
147
+
146
148
$ withTable = $ relation ->getRelated ()->getTable ();
147
149
148
- $ this ->repository ->join ($ withTable , "{$ withTable }. {$ foreignKey }" , "{$ currentTable }. {$ localKey }" );
149
- $ this ->repository ->orderBy ("{$ withTable }. {$ key }" , $ sortD );
150
+ $ withTableName = strpos ($ withTable , ". " ) === false ? $ withConnection . '. ' . $ withTable : $ withTable ;
151
+
152
+ $ this ->repository ->join ($ withTableName , "{$ withTableName }. {$ foreignKey }" , "{$ currentTable }. {$ localKey }" );
153
+ $ this ->repository ->orderBy ("{$ withTableName }. {$ key }" , $ sortD );
154
+
150
155
}
151
156
}
152
157
Original file line number Diff line number Diff line change @@ -254,6 +254,12 @@ public function get(array $columns = ['*'])
254
254
return $ models ;
255
255
}
256
256
257
+ public function dd (array $ columns = ['* ' ])
258
+ {
259
+ $ this ->newQuery ()->eagerLoad ()->setClauses ()->setScopes ();
260
+ $ this ->query ->dd ($ columns );
261
+ }
262
+
257
263
public function getRaw (array $ columns = ['* ' ])
258
264
{
259
265
$ this ->newQuery ()->eagerLoad ()->setClauses ()->setScopes ();
You can’t perform that action at this time.
0 commit comments