@@ -691,11 +691,10 @@ protected function defaultOrdering(): void
691691 })
692692 ->reject (fn ($ orderable ) => $ this ->isBlacklisted ($ orderable ['name ' ]) && ! $ this ->hasOrderColumn ($ orderable ['name ' ]))
693693 ->each (function ($ orderable ) {
694- $ column = $ this ->resolveRelationColumn ($ orderable ['name ' ]);
695-
696694 if ($ this ->hasOrderColumn ($ orderable ['name ' ])) {
697- $ this ->applyOrderColumn ($ column , $ orderable );
695+ $ this ->applyOrderColumn ($ orderable );
698696 } else {
697+ $ column = $ this ->resolveRelationColumn ($ orderable ['name ' ]);
699698 $ nullsLastSql = $ this ->getNullsLastSql ($ column , $ orderable ['direction ' ]);
700699 $ normalSql = $ this ->wrap ($ column ).' ' .$ orderable ['direction ' ];
701700 $ sql = $ this ->nullsLast ? $ nullsLastSql : $ normalSql ;
@@ -715,15 +714,15 @@ protected function hasOrderColumn(string $column): bool
715714 /**
716715 * Apply orderColumn custom query.
717716 */
718- protected function applyOrderColumn (string $ column , array $ orderable ): void
717+ protected function applyOrderColumn (array $ orderable ): void
719718 {
720719 $ sql = $ this ->columnDef ['order ' ][$ orderable ['name ' ]]['sql ' ];
721720 if ($ sql === false ) {
722721 return ;
723722 }
724723
725724 if (is_callable ($ sql )) {
726- call_user_func ($ sql , $ this ->query , $ orderable ['direction ' ], $ column );
725+ call_user_func ($ sql , $ this ->query , $ orderable ['direction ' ], fn ( $ column) => $ this -> resolveRelationColumn ( $ column ) );
727726 } else {
728727 $ sql = str_replace ('$1 ' , $ orderable ['direction ' ], (string ) $ sql );
729728 $ bindings = $ this ->columnDef ['order ' ][$ orderable ['name ' ]]['bindings ' ];
0 commit comments