Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zachflower/ignorable-observers
Dynamically disable/enable Laravel's Eloquent model observers.
https://github.com/zachflower/ignorable-observers
eloquent laravel laravel-package php
Last synced: 3 months ago
JSON representation
Dynamically disable/enable Laravel's Eloquent model observers.
- Host: GitHub
- URL: https://github.com/zachflower/ignorable-observers
- Owner: zachflower
- License: mit
- Created: 2017-02-06T23:16:25.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-01-28T17:50:52.000Z (almost 5 years ago)
- Last Synced: 2024-10-30T00:11:02.765Z (3 months ago)
- Topics: eloquent, laravel, laravel-package, php
- Language: PHP
- Homepage:
- Size: 13.7 KB
- Stars: 24
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Ignorable Observers
[![Code Climate](https://codeclimate.com/github/zachflower/ignorable-observers/badges/gpa.svg)](https://codeclimate.com/github/zachflower/ignorable-observers) [![build](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fzachflower%2Fignorable-observers%2Fbadge&label=build)](https://actions-badge.atrox.dev/zachflower/ignorable-observers/goto) [![Packagist](https://img.shields.io/packagist/v/zachflower/ignorable-observers.svg)]()
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:
```
composer require zachflower/ignorable-observers
```## Usage
To give an Eloquent model the ability to temporarily ignore observers, simply add the `IgnorableObservers` trait:
```php
$i
]);
}ExampleModel::unignoreObservableEvents();
```## Contributing
1. Fork it
1. Create your feature branch (`git checkout -b my-new-feature`)
1. Commit your changes (`git commit -am 'Add some feature'`)
1. Push to the branch (`git push origin my-new-feature`)
1. Create new [Pull Request](https://github.com/zachflower/ignorable-observers/compare)## License
Ignorable Observers is an open-sourced library licensed under the MIT license.