I'm using dingo/api laravel package to create an API.
I want to add success
key response to every API call. If we have an error, success: false
and if all is OK, then success: true
.
Final response must looks like this:
{
"success":true,
"data": [{}, {}]
}
I know that there is a ->setMeta($meta);
method to add extra keys like this :
$meta = array(
'success' => 'true',
'status_code' => 200
);
return $this->response->collection($users, new UserTransformer)->setMeta($meta);
that creates bellow response :
{
"data": [{}, {}],
"meta": {
"success": true,
"status_code": 200
},
}
As you can see ,setMeta
adds extra keys under a meta
key that I do not want that.
I readed it's Responses documentations but I could not find any solution.
How to do that?