# Scopes

## translatedIn(?string $locale = null)

Returns all posts being translated in english

```php
Post::translatedIn('en')->get();
```

## notTranslatedIn(?string $locale = null)

Returns all posts not being translated in english

```php
Post::notTranslatedIn('en')->get();
```

## translated()

Returns all posts with existing translations

```php
Post::translated()->get();
```

## withTranslation()

Eager loads translation relationship only for the default and fallback (if enabled) locale

```php
Post::withTranslation()->get();
```

## listsTranslations(string $translationField)

Returns an array containing pairs of post ids and the translated title attribute

```php
Post::listsTranslations('title')->get()->toArray();
```

```php
[
    ['id' => 1, 'title' => 'My first post'],
    ['id' => 2, 'title' => 'My second post']
]
```

## where translation

Filters posts by checking the translation against the given value

### whereTranslation(string $translationField, $value, ?string $locale = null)

```php
Post::whereTranslation('title', 'My first post')->first();
```

### orWhereTranslation(string $translationField, $value, ?string $locale = null)

```php
Post::whereTranslation('title', 'My first post')
    ->orWhereTranslation('title', 'My second post')
    ->get();
```

### whereTranslationLike(string $translationField, $value, ?string $locale = null)

```php
Post::whereTranslationLike('title', '%first%')->first();
```

### orWhereTranslationLike(string $translationField, $value, ?string $locale = null)

```php
Post::whereTranslationLike('title', '%first%')
    ->orWhereTranslationLike('title', '%second%')
    ->get();
```

## orderByTranslation(string $translationField, string $sortMethod = 'asc')

Sorts the model by a given translation column value

```php
Post::orderByTranslation('title')->get()
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.astrotomic.info/laravel-translatable/package/scopes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
