Usually, if you would like to pull all the users from a API, you would create something like this in your controller:
use App\Http\Resources\UserResource;
use App\User;
public function index(){
return UserResource::collection(User::all());
}
This would probably have an impact within the server memory consumption. Thanksfully, now with Laravel 6.0, we have the option to use the cursor() feature in our models.
So, instead ... we could execute the following:
use App\Http\Resources\UserResource;
use App\User;
public function index(){
return UserResource::collection(User::cursor());
}
Currently this code will trigger and exception
Call to undefined method Generator::first()
Usually, if you would like to pull all the users from a API, you would create something like this in your controller:
This would probably have an impact within the server memory consumption. Thanksfully, now with Laravel 6.0, we have the option to use the cursor() feature in our models.
So, instead ... we could execute the following:
Currently this code will trigger and exception
Call to undefined method Generator::first()
What do you think?