---
title: Models
---

# Models

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

## Introduction

All models in the Streams Platform eventually extends [Laravel's Eloquent models](https://laravel.com/docs/eloquent). This documentation will assume you are already familiar with Laravel models.

### Base Models

All models in the Streams Platform will extend the base `\Anomaly\Streams\Platform\Model\EloquentModel` class and therefore will have a number of basic features unique to the Streams Platform.

### Entry Models

Entry models are specific to the `streams` API. Not all models are `entry` models but all `entry` models extend `base` models.

## Hooks

All models are [Hookable](../core-concepts/hooks).

## Translatable

All models support translation. Though all models may not be translatable.

### Check Translatable

You can use the `isTranslatable` method to check if a model is translatable.

```php
if ($entry->isTranslatable()) {
    echo "Yes!";
}
```

```twig
{% if entry.isTranslatable() %}
    Yes!
{% endif %}

### Translating Queries

Please see [query builder](../database/query-builder) documentation.

### Translating Entries

You can use the `translate` method to return the translation of a given `locale` with optional `withFallback`.

> This is only necessary if non-active locale values are desired.{.tip}

```php
$entry->translate($locale = null, $withFallback = false);

echo $entry->translate('fr', true)->name;
```

```twig
{{ entry->translate('fr', true).name }}
```

### All Translations

You can return a collection of translations with the `getTranslations` method.

```php
foreach ($entry->getTranslations() as $translation) {
    echo "{$translation->name} ({$translation->locale})";
}
```

```twig
{% for translation in entry.getTranslations() %}
    {{ translation.name }} ({{ translation.locale }})
{% endfor %}
```
