mongodb / laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)
https://www.mongodb.com/docs/drivers/php/laravel-mongodb/
MIT License
7.02k stars 1.43k forks source link

Soft-delete doesn't seem to be working #291

Closed bipinu closed 10 years ago

bipinu commented 10 years ago

Thanks for the great work. Really appreciate it!

cleanunicorn commented 10 years ago

I have the same problem. Can you confirm if this is a library bug?

mhddurrah commented 10 years ago

I have not found this issue, added Jenssegers\Mongodb\Eloquent\SoftDeletingTrait not the laravel one, deleted an entry and found the deleted_at key, listing all entries via all(); returns all except with deleted_at. so it worked for me. screenshot_1

cleanunicorn commented 10 years ago

This fixed it for me.

bipinu commented 10 years ago

Dang! It took me another day but I finally figured it out. This particular behavior is displayed by Eloquent as well, and isn't limited Moloquent. However, this is not a bug with the library. Closing the issue.

Just for the record, if the your Model has a constructor, it needs to call the parent's constructor (Moloquent, Eloquent, etc.). This is because PHP does not implicitly call parent constructor, if you define one: http://php.net/manual/en/language.oop5.decon.php