---
title: Models
---

# Models

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

## Introduction

Entry models extend the [base models](../core-concepts/models).

## Field Values

### Attributes

Most field values are simply accessed like an attribute.

```php
$entry->first_name;
```

```twig
{{ entry.first_name }}
```

### Relations

Field types that provide a relationship generate a `relation` method on the `generated` model.

> The `relation method` will be camel case the `field slug`.{.tip}

```php
foreach ($entry->favoritePlayers()->orderBy('rating', 'DESC')->get() as $player) {
    echo "{$player->name} - {$player->rating}";
}
```

```twig
{% for player in entry.favoritePlayers().orderBy('rating', 'DESC').get %}
    {{ player.name }} - {{ player.rating }}
{% endfor %}
```

You can return the results of the collection by accessing it as an attribute.

```php
foreach ($entry->favorite_players as $player) {
    echo "{$player->name} - {$player->rating}";
}
```

```twig
{% for player in entry.favorite_players %}
    {{ player.name }} - {{ player.rating }}
{% endfor %}
```


## Decoration

All entry models `decorate` themselves.

[Entry Presenters](../entries/presenters){.link}
[Base Presenters](../templating/presenters){.link}

## Versioning

All entry models support `versioning`.

[Versioning](../core-concepts/versioning){.link}

