Download the PHP package wfeller/laravel-batch without Composer
On this page you can find all versions of the php package wfeller/laravel-batch. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wfeller/laravel-batch
More information about wfeller/laravel-batch
Files in wfeller/laravel-batch
Package laravel-batch
Short Description Insert, update or delete models in batch, while still firing model events.
License MIT
Homepage https://github.com/wfeller/laravel-batch
Informations about the package laravel-batch
Laravel Batch
Save and update your Eloquent models in batches while still firing model events.
Introduction
This package allows you to efficiently save, update, and delete many Eloquent models at once while maintaining Laravel's standard model event system. Unlike Laravel's native insert() method, this package fires all the normal model events (saving, saved, creating, created, updating, updated, deleting, deleted).
Installation
You can install the package via composer:
Quick Start
Core Features
1. Batch Saving Models
Save multiple models with a single operation:
2. Batch Updating Models
Update multiple existing models:
3. Batch Deleting Models
Delete multiple models efficiently:
4. Queue Support
Process batch operations in the background:
5. Model Trait Integration
Add batch functionality directly to your models:
6. Batch Size Configuration
Control how many models are processed in each batch:
Performance Comparison
| Method | Speed | Model Events |
|---|---|---|
Laravel's insert() |
Fastest | No |
| Laravel Batch | 1.3-3x slower than insert() |
Yes |
Individual create() calls |
8-50x slower than insert() |
Yes |
Event Handling
All standard Laravel model events are fired during batch operations:
Testing
Run the test suite:
Limitations
- Auto-increment IDs are not returned after batch insert.
batchSave()returns only IDs that were explicitly provided (e.g. UUID models). For auto-increment models, newly inserted rows do not have their database-assigned IDs populated on the model instance or included in the return value. Use UUID models if you need IDs immediately after batch insert.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email me instead of using the issue tracker.
License
This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you'll be creating employment for local families and restoring wildlife habitats.
You can buy trees here offset.earth/treeware
Read more about Treeware at treeware.earth
Credits
- William
- All Contributors
All versions of laravel-batch with dependencies
illuminate/bus Version ^11.0|^12.0|^13.0
illuminate/contracts Version ^11.0|^12.0|^13.0
illuminate/database Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0