All Projects → monooso → unobserve

monooso / unobserve

Licence: MIT license
Mute and unmute Laravel observers at will.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to unobserve

Laravel Multilingual Routes
A package to handle multilingual routes in your Laravel application.
Stars: ✭ 241 (+193.9%)
Mutual labels:  laravel-package
Instagram-for-PHP
PHP SDK for Instagram API
Stars: ✭ 82 (+0%)
Mutual labels:  laravel-package
laravel-migrate-check
An artisan command to check for pending migrations with proper exit code
Stars: ✭ 53 (-35.37%)
Mutual labels:  laravel-package
Laravel Localization
Easy localization for Laravel
Stars: ✭ 2,816 (+3334.15%)
Mutual labels:  laravel-package
madzipper
Wannabe successor of Chumper/Zipper package for Laravel
Stars: ✭ 114 (+39.02%)
Mutual labels:  laravel-package
formoj
Form generator package for Laravel
Stars: ✭ 28 (-65.85%)
Mutual labels:  laravel-package
Laravel Query Monitor
Simple artisan command to monitoring triggered queries
Stars: ✭ 230 (+180.49%)
Mutual labels:  laravel-package
laravel-jwt
A seamless JWT implementation for Laravel
Stars: ✭ 71 (-13.41%)
Mutual labels:  laravel-package
nova-rating-field
A Star rating field to use in your Laravel Nova apps.
Stars: ✭ 42 (-48.78%)
Mutual labels:  laravel-package
LaravelPostcodes
A service wrapper around postcodes.io
Stars: ✭ 73 (-10.98%)
Mutual labels:  laravel-package
Nexmo Laravel
Add Nexmo functionality such as SMS and voice calling to your Laravel app with this Laravel Service Provider.
Stars: ✭ 250 (+204.88%)
Mutual labels:  laravel-package
Translation Sheet
Translating Laravel languages files using a Google Spreadsheet.
Stars: ✭ 254 (+209.76%)
Mutual labels:  laravel-package
blurhash
A PHP implementation of BlurHash with Laravel integration.
Stars: ✭ 46 (-43.9%)
Mutual labels:  laravel-package
Laravel Gitscrum
GitScrum is a Project Management Tool, developed to help entrepreneurs, freelancers, managers, and teams Skyrocket their Productivity with the Agile methodology and Gamification.
Stars: ✭ 2,686 (+3175.61%)
Mutual labels:  laravel-package
trader
Laravel package for trader extension interface.
Stars: ✭ 43 (-47.56%)
Mutual labels:  laravel-package
Auth Tests
Always-current tests for Laravel's authentication system. Curated by the community.
Stars: ✭ 230 (+180.49%)
Mutual labels:  laravel-package
boilerplate
Laravel AdminLTE 3 Boilerplate package with blade components, users, roles and permissions management
Stars: ✭ 167 (+103.66%)
Mutual labels:  laravel-package
laravel-api-tool-kit
Laravel api tool kit is a set of tools that will help you to build a fast and well-organized API using laravel best practices.
Stars: ✭ 107 (+30.49%)
Mutual labels:  laravel-package
openfoodfacts-laravel
Open Food Facts API wrapper for Laravel
Stars: ✭ 117 (+42.68%)
Mutual labels:  laravel-package
laravel-packages
Useful packages for Laravel projects
Stars: ✭ 22 (-73.17%)
Mutual labels:  laravel-package

Unobserve

Lint and Test Status Quality Score Coverage Latest Stable Version License

About Unobserve

When testing Laravel applications, we frequently need to "silence" events, so as not to trigger additional side-effects. Laravel's Event::fake method is useful, but muting a specific model observer is still problematic.

Unobserve takes care of that, making it easy to mute and unmute an observer at will.

Requirements and installation

Select the appropriate branch for your version of Laravel.

Branch Laravel Versions PHP Version
1.x ^5.8, ^6.0 ^7.2
2.x ^7.0 ^7.2.5
3.x ^8.0 ^7.3.0
4.x ^8.0 ^8.0.0
5.x ^9.0 ^8.0.0

Install Unobserve using Composer:

composer require monooso/unobserve

Usage

First, add the CanMute trait to your observer class.

<?php

namespace App\Observers;

use Monooso\Unobserve\CanMute;

class UserObserver
{
    use CanMute;
}

You can now mute and unmute your observer as needed:

UserObserver::mute();
UserObserver::unmute();

Mute options

Mute all observer events:

UserObserver::mute();

Mute specific observer events:

UserObserver::mute('creating');
UserObserver::mute(['creating', 'created']);

License

Unobserve is open source software, released under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].