---
title: Events
---

# Events

<div class="documentation__toc"></div>

## Introduction

Streams dispatches a number of helpful Laravel type [events](../../core-concepts/events).

Any data passed to the event that is documented can be accessed via an accessor method: 

```php
// The dispatched event.
app('events')->dispatch(new \Anomaly\Streams\Platform\Addon\Event\AddonsHaveRegistered($addons));

// Within your listener.
$addons = $event->getAddons();
```

## Request Lifecycle

### Booting

This event is fired as soon as `StreamsServiceProvider::boot()` starts.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Event\Booting());
```

### Booted

This event is fired as soon as `StreamsServiceProvider::booted()` starts. This is after the Streams Platform boots but before registering addons.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Event\Booted());
```

### AddonsHaveRegistered

This event is fired after all the addon service providers have been registered but before the Streams Platform boot process has proceeded. The event contains the `addon collection`.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Addon\Event\AddonsHaveRegistered($addons));
```

### Ready

This event is fired after the Streams Platform has booted and all addons have been registered and booted and the system is ready to respond.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Event\Ready());
```


## Addon Management

### ModuleWasInstalled

This event is fired after a module is installed. The event contains the installed `module`.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Addon\Module\Event\ModuleWasInstalled($module));
```

### ModuleWasUninstalled

This event is fired after a module is uninstalled. The event contains the uninstalled `module`.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Addon\Module\Event\ModuleWasUninstalled($module));
```

### ModuleWasEnabled

This event is fired after a module is enabled. The event contains the enabled `module`.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Addon\Module\Event\ModuleWasEnabled($module));
```

### ModuleWasDisabled

This event is fired after a module is disabled. The event contains the disabled `module`.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Addon\Module\Event\ModuleWasDisabled($module));
```

### ExtensionWasInstalled

This event is fired after a extension is installed. The event contains the installed `extension`.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Addon\Extension\Event\ExtensionWasInstalled($extension));
```

### ExtensionWasUninstalled

This event is fired after a extension is uninstalled. The event contains the uninstalled `extension`.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Addon\Extension\Event\ExtensionWasUninstalled($extension));
```

### ExtensionWasEnabled

This event is fired after a extension is enabled. The event contains the enabled `extension`.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Addon\Extension\Event\ExtensionWasEnabled($extension));
```

### ExtensionWasDisabled

This event is fired after a extension is disabled. The event contains the disabled `extension`.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Addon\Extension\Event\ExtensionWasDisabled($extension));
```


## Control Panel

### GatherNavigation

This event is fired after the default control panel navigation is set and any additional navigation items are allowed to be added to the builder. The event contains the control panel `builder` instance.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Ui\ControlPanel\Component\Navigation\Event\GatherNavigation($builder));
```

### GatherSections

This event is fired after the default control panel sections are set and any additional sections items are allowed to be added to the builder. The event contains the control panel `builder` instance.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Ui\ControlPanel\Component\Section\Event\GatherSections($builder));
```

### GatherShortcuts

This event is fired after the default control panel shortcuts are set and any additional shortcuts items are allowed to be added to the builder. The event contains the control panel `builder` instance.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Ui\ControlPanel\Component\Shortcut\Event\GatherShortcuts($builder));
```

### ControlPanelWasBuilt

This event is fired after the control panel is built and ready to handle the request. The event contains the control panel `builder` instance.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Ui\ControlPanel\Event\ControlPanelWasBuilt($builder));
```


## Form Builders

### FormWasBuilt

This event is fired after the form builder is built and ready to respond. The event contains the form `builder` instance.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Ui\Form\Event\FormWasBuilt($builder));
```

### FormWasPosted

This event is fired after the form builder has been built and is about to handle a `POST` request. The event contains the form `builder` instance.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Ui\Form\Event\FormWasPosted($builder));
```

### FormWasSaved

This event is fired after the form builder has been built, posted, and has `saved` the model but before the response has been generated. The event contains the form `builder` instance.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Ui\Form\Event\FormWasSaved($builder));
```


## Table Builders

### TableIsQuerying

This event is fired at the beginning of the query process for table builders. The event contains the table `builder` instance and the `query` builder object.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Ui\Table\Event\TableIsQuerying($builder, $query));
```

### TableWasQuerying

This event is fired at the end of the query process for table builders. The event contains the table `builder` instance and the `query` builder object.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Ui\Table\Event\TableWasQuerying($builder, $query));
```


## Tree Builders

### TreeIsQuerying

This event is fired at the beginning of the query process for tree (list) builders. The event contains the tree `builder` instance and the `query` builder object.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Ui\Tree\Event\TreeIsQuerying($builder, $query));
```



## Entry Models

### EntryWasCreated

This event is fired just after an entry is created. The event contains the `entry` that was created.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Entry\Event\EntryWasCreated($entry));
```

### EntryWasUpdated

This event is fired just after an entry is updated. The event contains the `entry` that was updated.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Entry\Event\EntryWasUpdated($entry));
```

### EntryWasSaved

This event is fired just after an entry is saved (created or updated). The event contains the `entry` that was saved.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Entry\Event\EntryWasSaved($entry));
```

### EntryWasDeleted

This event is fired just after an entry is deleted. The event contains the `entry` that was deleted.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Entry\Event\EntryWasDeleted($entry));
```

This event is fired both when entries are deleted _and_ trashed. You can use the `isForceDeleting()` method to check if the entry is being trashed or (force) deleted:

```php
public function handle(EntryWasDeleted $event) {
    $entry = $event->getEntry();
    
    if ($entry->isForceDeleting()) {
        // Row was deleted.
    } else {
        // Row was trashed.
    }
}
```

### EntryWasRestored

This event is fired just after a trashed entry is restored. The event contains the `entry` that was restored.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Entry\Event\EntryWasRestored($entry));
```


## Eloquent Models

### ModelWasCreated

This event is fired just after an model is created. The event contains the `model` that was created.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Model\Event\ModelWasCreated($model));
```

### ModelWasUpdated

This event is fired just after an model is updated. The event contains the `model` that was updated.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Model\Event\ModelWasUpdated($model));
```

### ModelsWereUpdated

This event is fired just after models are updated. The event contains the `model` associated with those that were updated.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Model\Event\ModelsWereUpdated($model));
```

### ModelWasSaved

This event is fired just after an model is saved (created or updated). The event contains the `model` that was saved.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Model\Event\ModelWasSaved($model));
```

### ModelWasDeleted

This event is fired just after an model is deleted. The event contains the `model` that was deleted.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Model\Event\ModelWasDeleted($model));
```

This event is fired both when entries are deleted _and_ trashed. You can use the `isForceDeleting()` method to check if the model is being trashed or (force) deleted:

```php
public function handle(ModelWasDeleted $event) {
    $model = $event->getModel();
    
    if ($model->isForceDeleting()) {
        // Row was deleted.
    } else {
        // Row was trashed.
    }
}
```

### ModelsWereDeleted

This event is fired just after multiple models are deleted. The event contains the `model` associated to the deleted models.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Model\Event\ModelsWereDeleted($model));
```

This event is fired both when entries are deleted _and_ trashed. You can use the `isForceDeleting()` method to check if the model is being trashed or (force) deleted:

```php
public function handle(ModelsWereDeleted $event) {
    $model = $event->getModel();
    
    if ($model->isForceDeleting()) {
        // Rows were deleting.
    } else {
        // Rows were being trashed.
    }
}
```

### ModelWasRestored

This event is fired just after a trashed model is restored. The event contains the `model` that was restored.

```php
app('events')->dispatch(new \Anomaly\Streams\Platform\Model\Event\ModelWasRestored($model));
```
