Download the PHP package stfn/laravel-pending-updates without Composer
On this page you can find all versions of the php package stfn/laravel-pending-updates. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-pending-updates
Postpone model updates or temporarily keep them updated for some time
When updating an Eloquent model, by using this package, you can postpone updating process for some time.
The model itself will not be updated in this case. The package will just schedule an update for you. So this news will be active only on 1st January for the whole day and after that, the package will revert the news to its previous state.
Installation
You can install the package via composer:
You can publish and run the migrations with:
You can publish the config file with:
This is the contents of the published config file:
When running the console command pending-updates:check
all pending updates will be checked
and if there is a need to revert some update to original table, this command will do that for you.
That command needs to be scheduled in the Laravel console kernel.
Usage
You should add the HasPendingUpdates trait to all models which need to have a pending update option.
With this in place, you will be able to postpone update of this model.
Using keep for
By using keep for, update will be performed at the moment, but package will revert changes after specific number of minutes, hours or days.
Using delay for
By using delay for, update will be performed later, after specific number of minutes, hours or days.
Using timestamps
You can also use timestamps to specify exact time when you want to update some model.
Using combination
A combination of specific minutes, hours, or days with timestamps is also possible.
Using methods on the model
By default, all fillable attributes are allowed to be postponed, but you can change that by overriding
allowedPendingAttributes
method.
Keep in mind that those fields also need to be fillable.
Sometimes scheduled update may fail, for various reasons.
By default, the package will send that exception to your configured external
report service like Sentry, Flare, or Bugsnag and after that,
the record from the pending_updates
table will be removed. If you want to change this behavior, you can
override the updateCannotBeApplied
method on the PendingUpdateModel
.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
- Stefan Damjanovic
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-pending-updates with dependencies
spatie/laravel-package-tools Version ^1.14.0
illuminate/contracts Version ^9.0|^10.0