When using mysql driver in Laravel, save the following code
$result = $model->create($data);
$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!
This is because of code problems.