{"id":22889599,"url":"https://github.com/dillingham/soft-deletes-parent","last_synced_at":"2025-08-25T16:13:38.953Z","repository":{"id":41139108,"uuid":"418994082","full_name":"dillingham/soft-deletes-parent","owner":"dillingham","description":"Laravel soft delete children when parent soft deletes","archived":false,"fork":false,"pushed_at":"2021-10-19T19:52:30.000Z","size":25,"stargazers_count":59,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-15T16:45:59.020Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dillingham.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null},"funding":{"github":"dillingham"}},"created_at":"2021-10-19T15:56:55.000Z","updated_at":"2025-04-17T19:21:58.000Z","dependencies_parsed_at":"2022-09-08T05:40:32.329Z","dependency_job_id":null,"html_url":"https://github.com/dillingham/soft-deletes-parent","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":"dillingham/package-skeleton-laravel","purl":"pkg:github/dillingham/soft-deletes-parent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dillingham%2Fsoft-deletes-parent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dillingham%2Fsoft-deletes-parent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dillingham%2Fsoft-deletes-parent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dillingham%2Fsoft-deletes-parent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dillingham","download_url":"https://codeload.github.com/dillingham/soft-deletes-parent/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dillingham%2Fsoft-deletes-parent/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272093576,"owners_count":24872188,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-25T02:00:12.092Z","response_time":1107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-13T21:56:19.895Z","updated_at":"2025-08-25T16:13:38.903Z","avatar_url":"https://github.com/dillingham.png","language":"PHP","funding_links":["https://github.com/sponsors/dillingham"],"categories":[],"sub_categories":[],"readme":"# Laravel Soft Deletes Parent\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/dillingham/soft-deletes-parent.svg?style=flat-square)](https://packagist.org/packages/dillingham/soft-deletes-parent)\n[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/dillingham/soft-deletes-parent/run-tests?label=tests)](https://github.com/dillingham/soft-deletes-parent/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/dillingham/soft-deletes-parent/Check%20\u0026%20fix%20styling?label=code%20style)](https://github.com/dillingham/soft-deletes-parent/actions?query=workflow%3A\"Check+%26+fix+styling\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/dillingham/soft-deletes-parent.svg?style=flat-square)](https://packagist.org/packages/dillingham/soft-deletes-parent)\n\n---\n\nAutomatically 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. \n\n---\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require dillingham/soft-deletes-parent\n```\n\n## Usage\nAdd the `parent_deleted_at` column to your table:\n```php\nSchema::table('posts', function (Blueprint $table) {\n    $table-\u003esoftDeletesParent();\n});\n```\nAnd add the trait and parent model to your child model:\n```php\n\u003c?php\n\nnamespace App\\Models;\n\nuse Dillingham\\SoftDeletesParent\\SoftDeletesParent;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Post extends Model\n{\n    use SoftDeletesParent;\n}\n```\n```php\n\u003c?php\n\nnamespace App\\Providers;\n\nclass AppServiceProvider\n{\n    public function register()\n    {\n        Post::softDeletesParent(Author::class);\n    }\n}\n```\n\n### Scopes\n\nWith parent trashed:\n```php\nPost::withParentTrashed()-\u003eget();\n```\nOnly parent trashed:\n```php\nPost::onlyParentTrashed()-\u003eget();\n```\n\n## Testing\n\n```bash\ncomposer test\n```\n## Contributing\n\nPlease see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Brian Dillingham](https://github.com/dillingham)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdillingham%2Fsoft-deletes-parent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdillingham%2Fsoft-deletes-parent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdillingham%2Fsoft-deletes-parent/lists"}