I have a Laravel API call, and I want to paginate the result, but can't seem to find the way that works. My call looks like this:
public function index(Request $request){
$per_page = $request->input('per_page');
if(!$per_page)
$per_page=20;
$creditos = Prestacion::all();
$creditos = $creditos->paginate($per_page);
return $this->collection($creditos, new PrestacionTransformer);
}
This returns the error:
"Method Illuminate\Database\Eloquent\Collection::paginate does not exist."