My Model:
use MongoDB\Laravel\Eloquent\Model;
use MongoDB\Laravel\Relations\EmbedsOne;
class TextContent extends Model {
public function lock(): EmbedsOne
{
return $this->embedsOne (TextLock::class);
}
}
class TextLock extends Model
{
}
This is how store a TextLock:
$lock = new TextLock();
$textContent->lock()->associate ($lock);
$textContent->save();
But I cannot delete it. I tried these methods:
$textContent->lock->delete();
$textContent->save();
// not working, $textContent->lock is still present
// weirdly: $textContent->lock has new prop named 'lock' after this operation. So we have $textContent->lock is `{lock: null}`
$textContent->lock()->delete();
// results in error: MongoDB\Laravel\Relations\EmbedsOne::delete(): Return value must be of type int, true returned
$textContent->lock = null;
$textContent->save();
// not working, $textContent->lock is still present
Any ideas?
I'm using this package: https://github.com/mongodb/laravel-mongodb
jenssegers/laravel-mongodbpackage or any other package?please specify.jenssegers/laravel-mongodbpackage, in the meanwhile developers of mongodb overtook the maintaince, so it'smongodb/laravel-mongodb: github.com/mongodb/laravel-mongodbdelete()you can try withdissociate().Don't forget to inform the outcome of this.