File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -188,7 +188,9 @@ public function orderByUsingJoins()
188188
189189 $ this ->joinRelationship (implode ('. ' , $ relationships ));
190190
191- $ latestRelationshipModel = $ this ->getModel ()->$ latestRelationshipName ()->getModel ();
191+ $ latestRelationshipModel = array_reduce ($ relationships , function ($ model , $ relationshipName ) {
192+ return $ model ->$ relationshipName ()->getModel ();
193+ }, $ this ->getModel ());
192194
193195 if ($ aggregation ) {
194196 $ this ->selectRaw (
Original file line number Diff line number Diff line change @@ -34,17 +34,17 @@ public function test_order_by_relationship()
3434 public function test_order_by_nested_relationship ()
3535 {
3636 // just making sure the query doesn't throw any exceptions
37- User::orderByUsingJoins ('posts.comments.approved ' , 'desc ' )->get ();
37+ User::orderByUsingJoins ('posts.category.title ' , 'desc ' )->get ();
3838
39- $ query = User::orderByUsingJoins ('posts.comments.approved ' , 'desc ' )->toSql ();
39+ $ query = User::orderByUsingJoins ('posts.category.title ' , 'desc ' )->toSql ();
4040
4141 $ this ->assertStringContainsString (
4242 'select "users".* from "users" ' ,
4343 $ query
4444 );
4545
4646 $ this ->assertStringContainsString (
47- 'order by "comments "."approved " desc ' ,
47+ 'order by "categories "."title " desc ' ,
4848 $ query
4949 );
5050 }
You can’t perform that action at this time.
0 commit comments