mardi 3 novembre 2015

Laravel 5: How to use remote model?

I want to create a model for external API, that would allow me to run operations like get(), where() etc. An example:

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

I come to Laravel from CakePHP. In CakePHP it's done by providing custom datasource and connection for the model.

For Laravel 4 there's a nice library called Trucker (http://ift.tt/1OlinLb), but I've found absolutely no other reasonable tool for L5.

What is the correct approach to the problem of "mapping model to external api"?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire