laravel 4 observer code example
Example 1: laravel observer events
retrieved
creating
created
updating
updated
saving
saved
deleting
deleted
restoring
restored
Example 2: laravel observer
<?php
namespace App\Providers;
use App\Observers\UserObserver;
use App\Models\User;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
User::observe(UserObserver::class);
}
}