Asserting that an Eloquent model soft deletes
This blog post was originally published a little while ago. Please consider that it may no longer be relevant or even accurate.
Ran into an unpleasant situation recently where I discovered a model that I thought was soft-deleting wasn't actually - database records were actually being removed. This meant that a few months of reporting data were thrown off completely and a lot of content was lost forever.
In addition to adding the SoftDeletes
trait back to the model I also added tests to ensure this didn't happen again. Here's a small PHPUnit helper that might help you do the same.
It's easy to use, just pass the model's class name and you should be good to go.