R
R
RealSamson2015-10-14 05:06:28
API
RealSamson, 2015-10-14 05:06:28

How to make readable url for api (laravel)?

I'm writing a small, public api that takes a few parameters and returns a response. Also there was a question about url. Based on the article , the url should look like this:
GET /dogs?color=red&state=running&location=park
But, I did not find examples of how to do it in laravel (neither in the docks, nor in blogs).
Right now, my working version looks like this:
GET /api/v1/dogs/dogs=labrador
and routes.php

Route::group(['prefix' => 'api/v1/dogs'], function()
{
  Route::get('/dogs={dogs}', '[email protected]');
});

Any options on how to prepare routes.php?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
D', 2015-10-14
@RealSamson

What kind of perversion?
You either just need to specify:
And resolve GET parameters through Request (Create your own APIDogsRequest and set the required fields)
Or like this:
But then the parameters are not named, and it is more difficult to resolve in Request.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question