Download the PHP package litvinjuan/laravel-cascade-soft-deletes without Composer
On this page you can find all versions of the php package litvinjuan/laravel-cascade-soft-deletes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download litvinjuan/laravel-cascade-soft-deletes
More information about litvinjuan/laravel-cascade-soft-deletes
Files in litvinjuan/laravel-cascade-soft-deletes
Package laravel-cascade-soft-deletes
Short Description Cascades soft delete and restored operations to the defined relationships
License MIT
Homepage https://github.com/litvinjuan/laravel-cascade-soft-deletes
Informations about the package laravel-cascade-soft-deletes
Cascades soft delete and restore operations in Laravel Models
This package is for cascading soft delete and restore operations on your related models. When a model gets soft deleted, the configured related models get soft deleted as well. When the original model is restored, its soft-deleted related models algo get restored.
Installation
You can install the package via composer:
You can publish the config file with:
Soft Deleting
Simply add the trait to your models and configure the cascading relations either via the cascadeSofDeleteRelations
property or the getRelationsForCascadeSoftDeletes
method.
If your cascading related model also has the CascadeSoftDeletes
trait, its related models will also be soft-deleted.
In the following example, soft deleting a project, will also soft delete its tasks. And soft deleting a team, will soft delete its projects, and in turn, all their respective tasks will also be soft deleted.
Restoring
Restoration works very similarly. By default, it restores the same relations that were soft deleted, but you can customize the relations to be restored by setting the cascadeRestoreRelations
or implementing the getRelationsForCascadeRestore
.
If you want to disable restoration all together, go into the cascade-soft-deletes
config and set cascade_restores
to false
.
By default, when restoring related models, the package will only restore models that were deleted at the same time or after the parent model. This is to make sure we don't restore a child model that was soft deleted individually in a previous time. If you want to restore all models regardless of when they were soft deleted, you can go into the configuration file and set ignore_deleted_at_when_restoring
to true
.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Juan Litvin
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-cascade-soft-deletes with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^10.0||^11.0