Download the PHP package exls/laravel-cascade-soft-deletes without Composer
On this page you can find all versions of the php package exls/laravel-cascade-soft-deletes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download exls/laravel-cascade-soft-deletes
More information about exls/laravel-cascade-soft-deletes
Files in exls/laravel-cascade-soft-deletes
Package laravel-cascade-soft-deletes
Short Description Cascading queued or regular deletes and restores for Eloquent models that implement soft deletes
License MIT
Informations about the package laravel-cascade-soft-deletes
Laravel CascadeSoftDeletes
Introduction
In scenarios when you delete a parent record you may want to also delete any detail/child associated with it as a form of self-maintenance of your data.
Normally, you would use your database's foreign key constraints, adding an ON DELETE CASCADE
rule to the foreign key constraint in your detail/child table.
If you need to be able to restore a parent record after it was deleted, check you may reach for Laravel's soft deleting functionality.
But in this case you can use database feature to cascade delete details. This package support cascade soft deletes feature and support queues to make last one.
Installation
Pull this package in through Composer.
Laravel 5.* Integration
Add the service provider to your config/app.php
file:
Usage
Change SoftDeletes trait in your models to CascadeSoftDeletes trait from this package
Now you can delete an App\Models\Master
record, and any associated App\Models\Master\Detail
records will be deleted. If the App\Models\Master\Detail
record use the CascadeSoftDeletes
trait as well, it's details/children will also be deleted and so on.
Tests
Contact
Anton Pavlov
- Email: [email protected]