Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Translatable Laravel Package

astrotomic/laravel-translatable

Laravel package for translatable Eloquent models. Store model translations in the database and automatically fetch/save multilingual attributes based on locale, reducing boilerplate when working with multi-language content.

View on GitHub
Deep Wiki
Context7

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 with existing translations

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

withTranslation()

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

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

listsTranslations(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()
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope