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?
@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.
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->uuidworks because the Request object's__getmethod tries to get the property from the inputs, and if that fails, tries to get the value from the route associated with the request.