Download the PHP package cesargb/laravel-model-toolkit without Composer
On this page you can find all versions of the php package cesargb/laravel-model-toolkit. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-model-toolkit
Laravel Model Toolkit
[](https://github.com/cesargb/laravel-model-toolkit/actions/workflows/tests.yml) [](https://github.com/cesargb/laravel-model-toolkit/actions/workflows/static-analysis.yml) [](https://github.com/cesargb/laravel-model-toolkit/actions/workflows/lint.yml)A Laravel package that automatically discovers all Eloquent models, detects orphaned records in polymorphic relationships, and removes unwanted entries. It also executes cleanup for prunable models in a single pass.
What Does This Package Do?
When you delete a parent model (for example, a Post), related tables
using polymorphic relationships (such as images, comments, or
taggables) may retain records pointing to IDs that no longer exist.
These are considered orphaned records.
This package:
- ✅ Automatically scans all Eloquent models in your application
- ✅ Detects and removes orphaned records in polymorphic relationships
- ✅ Detects and executes cleanup for models using Laravel's
PrunableorMassPrunabletraits in the same command
Requirements
- PHP 8.4 or higher
- Laravel 12 or higher
Installation
Install the package via Composer:
Available Commands
model:clean
Displays orphaned records and prunable models, then removes them.
Options
--pretend; Preview what would be deleted without actually deleting records
--chunk=1000; Number of records processed per batch during deletion
model:list
Lists all discovered Eloquent models grouped by namespace along with their database tables.
Options
--json; Output results in JSON format
Programmatic Usage
You can also use the internal classes directly in your application code.
Retrieve All Polymorphic Relationships and Count Orphans
Clean Orphans for a Specific Model and Relation
List Prunable Models
This is useful if you want to integrate cleanup logic directly into your application instead of relying solely on Artisan commands.
License
This project is licensed under the MIT License, meaning you are free to use, modify, and distribute it.
All versions of laravel-model-toolkit with dependencies
illuminate/console Version ^12.0|^13.0
illuminate/database Version ^12.0|^13.0
illuminate/support Version ^12.0|^13.0
symfony/finder Version ^7.0