App\Providers\EventServiceProvider::boot PHP Method

boot() public method

Register any other events for your application.
public boot ( )
    public function boot()
    {
        parent::boot();
        // Generate a unique hash for a song from its path to be the ID
        Song::creating(function ($song) {
            $song->id = File::getHash($song->path);
        });
        // Remove the cover file if the album is deleted
        Album::deleted(function ($album) {
            if ($album->hasCover) {
                @unlink(app()->publicPath() . '/public/img/covers/' . $album->cover);
            }
        });
    }

Usage Example

 /**
  * Register any other events for your application.
  *
  * @param  \Illuminate\Contracts\Events\Dispatcher  $events
  * @return void
  */
 public function boot(DispatcherContract $events)
 {
     parent::boot($events);
     $events->listen('LoginEvent', 'Solunes\\Master\\App\\Listeners\\UserLoggedIn');
     $events->listen('eloquent.created: Solunes\\Master\\App\\Node', '\\Solunes\\Master\\App\\Listeners\\CreatedNode');
     $events->listen('eloquent.creating: Solunes\\Master\\App\\Menu', '\\Solunes\\Master\\App\\Listeners\\SavedMenu');
     $events->listen('eloquent.created: Solunes\\Master\\App\\Indicator', '\\Solunes\\Master\\App\\Listeners\\CreatedIndicator');
     $events->listen('eloquent.created: Solunes\\Master\\App\\IndicatorAlert', '\\Solunes\\Master\\App\\Listeners\\CreatedIndicatorChild');
     $events->listen('eloquent.created: Solunes\\Master\\App\\IndicatorGraph', '\\Solunes\\Master\\App\\Listeners\\CreatedIndicatorChild');
     $events->listen('eloquent.saved: *', '\\Solunes\\Master\\App\\Listeners\\RegisterActivityModel');
 }
All Usage Examples Of App\Providers\EventServiceProvider::boot
EventServiceProvider