PHPackages                             dillingham/soft-deletes-parent - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. dillingham/soft-deletes-parent

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

dillingham/soft-deletes-parent
==============================

Soft delete children when parent soft deletes

0.0.2(4y ago)561.3k3[1 issues](https://github.com/dillingham/soft-deletes-parent/issues)MITPHPPHP ^8.0

Since Oct 19Pushed 4y ago1 watchersCompare

[ Source](https://github.com/dillingham/soft-deletes-parent)[ Packagist](https://packagist.org/packages/dillingham/soft-deletes-parent)[ Docs](https://github.com/dillingham/soft-deletes-parent)[ GitHub Sponsors](https://github.com/dillingham)[ RSS](/packages/dillingham-soft-deletes-parent/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (8)Versions (3)Used By (0)

Laravel Soft Deletes Parent
===========================

[](#laravel-soft-deletes-parent)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d71e898151fc6f2e047516cc7da3187ecda915b363277106681f777ed1752ca4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64696c6c696e6768616d2f736f66742d64656c657465732d706172656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dillingham/soft-deletes-parent)[![GitHub Tests Action Status](https://camo.githubusercontent.com/af99a6d90211ade041293659535faedb63d4904fa9bf228745a7f4417e794ab5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f64696c6c696e6768616d2f736f66742d64656c657465732d706172656e742f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/dillingham/soft-deletes-parent/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/7c3a29832e7e8bcf562dbbdb67b24522bc7b2c10173696a6ffc381a8dfa11060/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f64696c6c696e6768616d2f736f66742d64656c657465732d706172656e742f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/dillingham/soft-deletes-parent/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/085386d4fe4e1c123a54abd16e0edd92693311e5101e12353199d82f982903c2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64696c6c696e6768616d2f736f66742d64656c657465732d706172656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dillingham/soft-deletes-parent)

---

Automatically soft delete a model's children while maintaining their own soft deleted state when you restore the parent model. After installing the trait below, the `Post` model's `parent_deleted_at` will update whenever an `Author` model is deleted or restored. This allows you to maintain the original `deleted_at` for the `Post` model after `Author` is restored. The `Post` model will scope queries to exclude any where the parent is deleted.

---

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require dillingham/soft-deletes-parent
```

Usage
-----

[](#usage)

Add the `parent_deleted_at` column to your table:

```
Schema::table('posts', function (Blueprint $table) {
    $table->softDeletesParent();
});
```

And add the trait and parent model to your child model:

```
