Closed Corben78 closed 2 years ago
By default if you have an endpoint such as GET /users
:
?name=john
to retreive all John users You will do something like this:
User::where('name', 'john')->get(); // Internally calls /users?name=john, It will return a Collection
Then if you have an endpoint GET /users/{id}
You will do such as below:
// User with id 1 exists in the API
// Internally calls /users/1, It will return a User model filled with data received from endpoint
User::find(1);
// User with id 2 does not exist in the API
// Returns null
User::find(2);
So if I well understood your question, it is already the default behavior for php-api-wrapper, but let me know if I didn't get your question.
Thanks for your answer. Sorry to answer this late, haven't had the chance to look into this more yet. Atm I'm using a different approach, but might come back to this later.
Is it possible to configure the API that's being queried to be like a RESTful (Laravel) API?
I see that when I request an item of a resource, that's done by adding GET parameters, e.g. https://example.com/users?id=1 But my API (provided via Laravel) is using URLs like this: https://example.com/users/1