laravel-translatable
Astrotomic
GitHub
IssueHunt
Search…
Introduction
Issues
Changelog
FAQ
Installation
Package
Interface
Methods
Scopes
Fallback locale
Locales helper
Validation Rule Factory
Usage
Attributes
Forms
Pivot Model
Powered By
GitBook
Scopes
translatedIn(?string $locale = null)
Returns all posts being translated in english
Post
::
translatedIn
(
'en'
)
->
get
();
notTranslatedIn(?string $locale = null)
Returns all posts not being translated in english
Post
::
notTranslatedIn
(
'en'
)
->
get
();
translated()
Returns all posts not being translated in any locale
Post
::
translated
()
->
get
();
withTranslation()
Eager loads translation relationship only for the default and fallback (if enabled) locale
Post
::
withTranslation
()
->
get
();
listTranslations(string $translationField)
Returns an array containing pairs of post ids and the translated title attribute
Post
::
listsTranslations
(
'title'
)
->
get
()
->
toArray
();
[
[
'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)
Post
::
whereTranslation
(
'title'
,
'My first post'
)
->
first
();
orWhereTranslation(string $translationField, $value, ?string $locale = null)
Post
::
whereTranslation
(
'title'
,
'My first post'
)
->
orWhereTranslation
(
'title'
,
'My second post'
)
->
get
();
whereTranslationLike(string $translationField, $value, ?string $locale = null)
Post
::
whereTranslationLike
(
'title'
,
'%first%'
)
->
first
();
orWhereTranslationLike(string $translationField, $value, ?string $locale = null)
Post
::
whereTranslationLike
(
'title'
,
'%first%'
)
->
orWhereTranslationLike
(
'title'
,
'%second%'
)
->
get
();
orderByTranslation(string $translationField, string $sortMethod = 'asc')
Sorts the model by a given translation column value
Post
::
orderByTranslation
(
'title'
)
->
get
()
Package - Previous
Methods
Next - Package
Fallback locale
Last modified
3yr ago
Copy link
Outline
translatedIn(?string $locale = null)
notTranslatedIn(?string $locale = null)
translated()
withTranslation()
listTranslations(string $translationField)
where translation
whereTranslation(string $translationField, $value, ?string $locale = null)
orWhereTranslation(string $translationField, $value, ?string $locale = null)
whereTranslationLike(string $translationField, $value, ?string $locale = null)
orWhereTranslationLike(string $translationField, $value, ?string $locale = null)
orderByTranslation(string $translationField, string $sortMethod = 'asc')