Kyslik / column-sortable

Package for handling column sorting in Laravel 5/6/7/8
MIT License
641 stars 105 forks source link

Sortable Union #190

Closed benyaminl closed 2 years ago

benyaminl commented 2 years ago

Hello, I want to ask, is there any possibility to make sortable works with Union? eg 2 diff table using union, but sortable() not works at all.

benyaminl commented 2 years ago

Forget it nvm

$data = A::query();
$data = B::query()->union($data)
if ($request->sort !=null && $request->direction !=null) {
            if ($request->direction == "desc") {
                $data = $data->orderByDesc($request->sort);
            } else {
                $data = $data->orderBy($request->sort);
            }
        }
$data = $data->paginate(5);