How do I create a new event?

To create a new event, we first have to scaffold the class using Artisan in the project root directory:

php artisan make:event Registered

The above command scaffolds a class into the app/Events and we can modify it accordingly to our needs.

After applying all the necessary functionality to the event, we have to also create a listener to listen to an event happening. In order for Aero to recognize the event, we have to specify it in a Service Provider of choice, for example, a module Service Provider:

protected $listen = [
        Registered::class => [
                // insert your listener here


Extending ManagedEvent

Aero’s ManagedEvent is an optional class made specifically for Aero events and is used mainly for mailing events. These are a special type of event as all the events that extend ManagedEvent are actions.

It’s important to note that the listener that listens to an event extending ManagedEvent, must also extend the ManagedListener class.



With ManagedEvent, we can create variables that can then be accessible in a mailing template. In essence, variables create helper text and allow the user to use data from the event itself. To define some variables, we have to create a property ‘variables’ in our event:


Adding variables

public static $variables = [

The above variables will then be accessible in our mail template.

An alternative method of adding variables:


Or multiple, as an array:

EventClass::addVariables([‘’, ‘product.lowest_price’])

Articles in this section

Was this article helpful?
0 out of 0 found this helpful