When using mysql driver in Laravel, save the following code
$result = $model->create($data);
Or
$model->name = 'name';
$result = $model->save();
After completion, $result will automatically obtain the current id and update the current model. to put it bluntly, $result returns the currently inserted model and contains the primary key.
However, using jenssegers/laravel-mongodb only returns a true or false after the addition is completed, and the primary key of the current model _id cannot be obtained. It is very inconvenient to use. I don’t know who has met and solved it. I hope you can help me, thank you!
PS:
laravel 5.1
jenssegers/laravel-mongodb ^2.2
https://d.laravel-china.org/d …
This is because of code problems.