I want to use JSON Response _id #3241
Unanswered
savasdersimcelik
asked this question in
General
Replies: 2 comments 1 reply
-
You can change the representation of the model to rename class Invoice
{
// ...
public function toArray()
{
$values = parent::toArray();
if (array_key_exists('id', $values)) {
$values['_id'] = $values['id'];
unset($values['id']);
}
return $values;
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
This comment was marked as disruptive content.
This comment was marked as disruptive content.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
With the example code above, I am returning a response to the mobile application API.
The response output is as follows:
Previously, in our mobile application, we accessed it with _id, but now it is all changed to id.
My problem is that I want to use _id in the JSON responses.
Beta Was this translation helpful? Give feedback.
All reactions