Pharaonic
Loading...

Scopes / Relationships

Scopes / Relationships

# Relationships

  • translations

# translated

Getting models that has been translated generally or in specific locale.

1$posts = Post::translated()->get(); // General
2$posts = Post::translated('en')->get(); // Localized
3 
4// Returns Illuminate\Database\Eloquent\Collection

# notTranslated

Getting models that has not been translated generally or in specific locale.

1$posts = Post::notTranslated()->get(); // General
2$posts = Post::notTranslated('en')->get(); // Localized
3 
4// Returns Illuminate\Database\Eloquent\Collection

# translatedSorting

Sorting the translated records depends on locale.

1$posts = Post::translatedSorting('en', 'title', 'asc')->get();
2 
3// Returns Illuminate\Database\Eloquent\Collection

# whereTranslation

Getting models that has ben translated with whereTranslation / orWhereTranslation conditions.

1$posts = Post::translated('en')
2 ->whereTranslation('column1', 'value')
3 ->orWhereTranslation('column2', 'value', 'en')
4 ->get();
5 
6// Returns Illuminate\Database\Eloquent\Collection

# whereTranslationLike

Getting models that has ben translated with whereTranslationLike / orWhereTranslationLike conditions.

1$posts = Post::translated('en')
2 ->whereTranslationLike('column1', '%' . $value . '%')
3 ->orWhereTranslationLike('column2', '%' . $value . '%', 'en')
4 ->get();
5 
6// Returns Illuminate\Database\Eloquent\Collection