Api: Laravel dd(request->all()) empty

Created on 8 Sep 2016  路  1Comment  路  Source: dingo/api

My route api looks like this

$api->get('{uuid}', ['uses' =>  'Api\v1\ConversationController@getConversationMessages']);

And when i do Validator it give me this outupt:

{
  "message": "Could not get user conversations.",
  "errors": {
    "uuid": [
      "The uuid field is required."
    ]
  },
  "status_code": 422
}

here how i validate the request:

        $validator = \Validator::make($request->all(),[
            'uuid' => 'required|alpha_dash'
        ]);

        if($validator->fails()) {
            throw new \Dingo\Api\Exception\ResourceException('Could not get user conversations.', $validator->errors());
        }

Also,
whenever i use $request->uuid, i do retrieve the value, but not in $request->all(),
I'm using postman api, do i need to setup additional settings?

Most helpful comment

@TwinLight That is because Laravel's all() method only pulls from the input, but {uuid} is a path or route parameter. $request->uuid works because the Request object's __get method tries to get the property from the inputs, and if that fails, tries to get the value from the route associated with the request.

>All comments

@TwinLight That is because Laravel's all() method only pulls from the input, but {uuid} is a path or route parameter. $request->uuid works because the Request object's __get method tries to get the property from the inputs, and if that fails, tries to get the value from the route associated with the request.

Was this page helpful?
0 / 5 - 0 ratings