I'm using Mongodb 3.2 with PHP in Laravel with Jensseger laravel-mongodb, documentation here: https://github.com/jenssegers/laravel-mongodb
I'm inserting data through this code and it works fine:
$clientes = DB::connection(env('DB_DATABASE'))->collection('catalogo_clientes');
$clientes->insert(array("_id" => "1", "nombre" => "test", "disponible" => 1));
However, I'd like to use a function I created in mongo instead of the "1" in the "_id", when inserting through the command line I'd normally use this, which works fine:
db.loadServerScripts();
db.catalogo_clientes.insert(
{
_id: getNextId("clientes"),
nombre: "Bob X.",
disponible: 1
}
)
How can I insert through php into mongo using the same function of "getNextId()"?