nicksynev/make-observer-command

Artisan command for creating Observer classes in Laravel
15,763 9
Install
composer require nicksynev/make-observer-command
Latest Version:v0.0.4
License:MIT
Last Updated:May 30, 2018
Links: GitHub  ·  Packagist
Maintainer: NickSynev

Total Downloads Latest Stable Version License

make-observer-command

Artisan command for creating observer classes in Laravel.

Tested on Laravel versions: 5.3, 5.4, 5.5, 5.6.

Installation

Install package via composer.

$ composer require nicksynev/make-observer-command

(Only for Laravel 5.4 and below) Add service provider into your app.php file in config folder.

NickSynev\MakeObserverCommand\MakeObserverCommandServiceProvider::class,

Usage

To add observer you need to enter class name. It will create Observers folder (if you dont have one) in your app directory and put class there. Also supports subfolder structure (for example User/UserObserver).

$ php artisan make:observer UserObserver

Additionally you can specify related model's namespace and methods.

$ php artisan make:observer UserObserver --model='App\Models\User' --methods=created,updated

There are 10 methods: creating, created, updating, updated, saving, saved, deleting, deleted, restoring, restored.

If no method chosen puts all of them to a class.

Do not forget to init your observer for example in AppServiceProvider boot method.

public function boot()
{
    User::observe(UserObserver::class);
    // Your code
}

Removal

(Only for Laravel 5.4 and below) Remove service provider from app.php.

Remove by composer.

$ composer remove nicksynev/make-observer-command

Related Packages

larapack/command-verification

Makes Artisan Commands prompt the console if it should continue.

15 1
larapack/command-validation

Enable a method for Artisan Commands to validate the output of methods like `ask...

4,261 12
robinfranssen/analyzelocale

This scans your laravel project for used locale keys that aren't translated by y...

21,198 25
guissilveira/laravel-pgsql-multi-tenant-migrate

Laravel Artisan command to migrate postgres multi tentant

188 1
hariadi/laravel-boilerplate-generator

Generate Model, attribute, relation, scope trait and repository for Laravel Boil...

609 9

Version History

Version Released Laravel License
v0.0.4 ~5 MIT
v0.0.3 ~5 MIT
v0.0.2 ~5 MIT
v0.0.1 ~5 MIT