> For the complete documentation index, see [llms.txt](https://yuga-framework.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yuga-framework.gitbook.io/documentation/database/elegant/events.md).

# Events

The Elegant ORM emits events at different intervals whenever something happens, You just have to hook into them.

### Triggering model events.

Whenever a model is accessed, whether by querying the database for records or inserting a record or updating a record or even deleting a record, events are triggered, they include:

* onCreating
* onCreated
* onSaving
* onSaved
* onUpdating
* onUpdated
* onDeleting
* onDeleted
* onSelecting
* onSelected

Each of the events is a method that you have to implement in your model as follows:

Let's say that you want to return all **fullnames** in **upper case** of users that exist in the database after you have selected them, this is how you would do it.

```php
<?php
namespace App\Models;

use Yuga\Models\ElegantModel as Elegant;

class User extends Elegant
{
    /**
     * @param \Yuga\Events\Dispatcher $event
     * @param \Yuga\Database\Elegant\Builder $query
     * @param \Yuga\Database\Elegant\Collection $results
     */
    public function onSelected($event, $query, $results)
    {
        return $results->map(function ($user) {
            $user->fullname = strtoupper($user->fullname);
            return $user;
        });
    }
}
```
