{"repo":"spatie/laravel-deleted-models","free":true,"listed":false,"github":"https://github.com/spatie/laravel-deleted-models","clone":"git clone https://github.com/spatie/laravel-deleted-models.git","description":"Automatically copy deleted records to a separate table","language":"PHP","stars":412,"topics":["deletion","eloquent","laravel","php"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"Automatically copy deleted records to a separate table When deleting an Eloquent model, this package will copy the attributes of that model to a new table called deleted models . You can view this as a sort of \"Recycle bin for models\". To restore a previous model you can call restore and pass the id. This way of preserving information when deleting can be seen as an alternative to soft deletes. You can read more on the trade-offs in this blog post. Support us We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products. We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall. Installation You can install the package via composer: To create the deleted models table, you can publish and run the migrations with: Optionally, you can publish the config file with: This is the contents of the published config file: The pruning of the deleted models table depends on Laravel's native pruning feature. Don't forget to schedule the model:prune as instructed in Laravel's docs. Usage You should add the KeepsDeletedModels trait to all models whose attributes should be written to deleted models whenever the model is deleted. With this in place, the attributes will be written to deleted models when the model is deleted. To restore a previous model you can ","default_branch":null,"files":null,"tree":[],"storefront":"/r/spatie","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/spatie/laravel-deleted-models/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}