View Code? Open in Web Editor
NEW
Prunable trait on models to delete them from database, including using queues
Shell 0.54%
PHP 61.18%
JavaScript 1.01%
Blade 10.17%
CSS 0.03%
Vue 27.08%
laravel-prune-models's Introduction
- Apply the
use Prunable
trait on a model
- Generate the
prunable
method to return a builder applying conditions of which models to delete
pruning
method is used to access the objects and apply methods on relations etc
- Run using
php artisan model:prune
- This will prune all models, select specific models using the --model options
- See all options with the --help flag
- Altneratively use the
MassPrunable
trait which will improve performance
- Only
Prunable
trait allows for pruning method as it retrieves a collection chunk of the models in memory, allowing for relation accessing
- Use
MassPrunable
when pruning method is not required as it has better performance
- Effective difference is
- Prunable:
Model::get()->delete()
- MassPrunable:
Model::delete()
- Prunable will also prune any soft delete models as it applies a force delete
laravel-prune-models's People
Contributors
Watchers