Models

Introduction

Entry models extend the base models.

Field Values

Attributes

Most field values are simply accessed like an attribute.

$entry->first_name;
{{ 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.

foreach ($entry->favoritePlayers()->orderBy('rating', 'DESC')->get() as $player) {
    echo "{$player->name} - {$player->rating}";
}
{% 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.

foreach ($entry->favorite_players as $player) {
    echo "{$player->name} - {$player->rating}";
}
{% for player in entry.favorite_players %}
    {{ player.name }} - {{ player.rating }}
{% endfor %}

Decoration

All entry models decorate themselves.

Entry Presenters Base Presenters

Versioning

All entry models support versioning.

Versioning