Download the PHP package zachflower/ignorable-observers without Composer
On this page you can find all versions of the php package zachflower/ignorable-observers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zachflower/ignorable-observers
More information about zachflower/ignorable-observers
Files in zachflower/ignorable-observers
Package ignorable-observers
Short Description Dynamically disable/enable Laravel's Eloquent model observers
License MIT
Informations about the package ignorable-observers
Ignorable Observers
Dynamically disable/enable Laravel's Eloquent model observers. This library provides the ability to temporarily disable observable events for Eloquent models. For example, temporarily disable observers that kick off emails, push notifications, or queued calculations when performing a large number of database inserts or updates.
Installation
Install using composer:
Usage
To give an Eloquent model the ability to temporarily ignore observers, simply add the IgnorableObservers
trait:
Then, call the ignoreObservableEvents()
static method to ignore all observers for that model:
The ignoreObservableEvents()
method also accepts an array of observers to be ignored. For example, the following line would ignore only the saved
and created
observers:
To stop ignoring a model's observers, call the unignoreObservableEvents()
static method:
The unignoreObservableEvents()
method also accepts an array of observers to unignore, giving you total control over which observers to enable and disable:
Example
The following example ignores any saved
and created
observers for the ExampleModel
, inserts 100 rows into the database, and then "unignores" those observers when the operation is completed:
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
License
Ignorable Observers is an open-sourced library licensed under the MIT license.