How to get GET method parameters by laravel 5

2019-07-21 02:30发布

I tried to make these code. then I send below request uri http://192.168.33.10/api/v1/company?data=test but, it can't get data parameter. Do you know how to get it?

Route.php

$api = app('Dingo\Api\Routing\Router');
$api->version('v1', function ($api) {
/* API */
$api->group(['prefix' => 'v1',
    'before' => 'v1',
    'middleware' => 'cors',
    'namespace' => 'App\\Http\\Controllers',
    'domain' => '192.168.33.10'
],function ($api) {
    // get company list
    $api->get('/company/', "CompaniesController@index");
});
});

controller.php

   public function index(UsersCreateRequest $request)
   {
    var_dump($request->input('data'));
    $users = $this->repository->all();

    return response()->json([
        'data' => $users,
    ]);
   }

1条回答
SAY GOODBYE
2楼-- · 2019-07-21 02:48

input method returns data of the form inputs. To get the query parameters you should use the query method:

var_dump($request->query('data'));
查看更多
登录 后发表回答