New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

nicksynev/make-observer-command

Artisan command for creating Observer classes in Laravel
15,791 9
Install
composer require nicksynev/make-observer-command
Latest Version:v0.0.4
Laravel:5
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-validation

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

4,261 12
larapack/command-verification

Makes Artisan Commands prompt the console if it should continue.

15 1
cpx/cpx

Run any command from any composer package, even if it's not installed in your pr...

83,692 540
tomshaw/laravel-calendar-table

A Laravel calendar table database migration and console command.

62,686 8
ollywarren/makepackage

Implements a Artisan command to scaffold out laravel composer packages

2,685 6

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