mercredi 4 novembre 2015

How to paginate records from API in Laravel

How to paginate/access in any reasonable way remote model based on external API? For Laravel 4 there's a nice library called Trucker (http://ift.tt/1OlinLb), but I've found absolutely no other tool for L5.

The only think I actually care about is how to accomplish code similar to this:

$users = UserFromApi::get(); // Get all users from api
$activeUsers = UserFromApi::where('active', 1)->get();

...with UserFromApi being REMOTE API, not in the database nor anywhere.

I can use simple get_file_contents() method, so it's not the request that's problematic, but the approach to do it in Laravel 5, so I can use a model.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire