I'm trying to get a list of users in MongoDB. The _id
is empty, so I can't process it properly.
How can I get the _id
of a document using MongoDB for Laravel?
{
"total": 1,
"per_page": 15,
"current_page": 1,
"last_page": 1,
"next_page_url": null,
"prev_page_url": null,
"from": 1,
"to": 1,
"data": [{
"_id": {},
"name": "Firstname Lastname",
"email": "user@gmail.com",
"password": "$2y$10$fmTpx5k0FdWC5HEqUcBtKe2nwZzt2nwSZ6oht8d3ytsuh5l7Kh8O2",
"updated_at": {},
"created_at": {},
"remember_token": "k7FQe0xbE5GJ6qPL9QK9CsHQrmBOKQkBO0zyKzkKibvRwnVL2tDXBBvK8zFW"
}]
}
In case somebody needs it, the data is returned by array. you can do a var_dump in blade using {{ var_dump ($user) }} and then you see the correct way to get the data is
{{ $user ["_id"] }}