YanTao's avatar

How to transformer the pagination data

I want to transformer the paginaton data , but it doesn't work.

$sort = $request->sort;
        $filter = $request->filter;
        $perPage = $request->per_page;
        $devis= $this->devisInterface->getAll($sort, $filter, $perPage);
        return $this->respondWithCollection($devis,new DevisTransformer());
0 likes
2 replies
jlrdw's avatar

Just do a query and orderBy

$users = DB::table('users')
                ->orderBy('name', 'desc')
                ->paginate(10); //or whatever no.
YanTao's avatar

I try it and it doesn't work.

Type error: Argument 1 passed to App\Http\Controllers\ApiController::respondWithCollection() must be an instance of Illuminate\Support\Collection, instance of Illuminate\Pagination\LengthAwarePaginator given, called in /home/vagrant/sites/luntai/app/Http/Controllers/DevisController.php on line 47", status_code: 500

1 like

Please or to participate in this conversation.