@@ -693,11 +693,10 @@ protected function defaultOrdering(): void
693693 })
694694 ->reject (fn ($ orderable ) => $ this ->isBlacklisted ($ orderable ['name ' ]) && ! $ this ->hasOrderColumn ($ orderable ['name ' ]))
695695 ->each (function ($ orderable ) {
696- $ column = $ this ->resolveRelationColumn ($ orderable ['name ' ]);
697-
698696 if ($ this ->hasOrderColumn ($ orderable ['name ' ])) {
699- $ this ->applyOrderColumn ($ column , $ orderable );
697+ $ this ->applyOrderColumn ($ orderable );
700698 } else {
699+ $ column = $ this ->resolveRelationColumn ($ orderable ['name ' ]);
701700 $ nullsLastSql = $ this ->getNullsLastSql ($ column , $ orderable ['direction ' ]);
702701 $ normalSql = $ this ->wrap ($ column ).' ' .$ orderable ['direction ' ];
703702 $ sql = $ this ->nullsLast ? $ nullsLastSql : $ normalSql ;
@@ -717,15 +716,15 @@ protected function hasOrderColumn(string $column): bool
717716 /**
718717 * Apply orderColumn custom query.
719718 */
720- protected function applyOrderColumn (string $ column , array $ orderable ): void
719+ protected function applyOrderColumn (array $ orderable ): void
721720 {
722721 $ sql = $ this ->columnDef ['order ' ][$ orderable ['name ' ]]['sql ' ];
723722 if ($ sql === false ) {
724723 return ;
725724 }
726725
727726 if (is_callable ($ sql )) {
728- call_user_func ($ sql , $ this ->query , $ orderable ['direction ' ], $ column );
727+ call_user_func ($ sql , $ this ->query , $ orderable ['direction ' ], fn ( $ column) => $ this -> resolveRelationColumn ( $ column ) );
729728 } else {
730729 $ sql = str_replace ('$1 ' , $ orderable ['direction ' ], (string ) $ sql );
731730 $ bindings = $ this ->columnDef ['order ' ][$ orderable ['name ' ]]['bindings ' ];
0 commit comments