Download the PHP package novius/laravel-translatable without Composer
On this page you can find all versions of the php package novius/laravel-translatable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download novius/laravel-translatable
More information about novius/laravel-translatable
Files in novius/laravel-translatable
Package laravel-translatable
Short Description A Laravel Eloquent model trait for translatable resource
License AGPL-3.0-or-later
Homepage https://github.com/novius/laravel-translatable
Informations about the package laravel-translatable
Laravel Translatable
Introduction
A package for making Laravel Eloquent models "translatable" using two fields: locale and locale_parent_id.
Requirements
- Laravel: 10.x, 11.x, 12.x, 13.x
- PHP: 8.2 – 8.5
Installation
You can install the package via composer:
You can publish lang files:
Usage
Migrations
Eloquent Model Trait
This trait adds:
- A relation
translationscontaining all translations of the model - A relation
translationsWithDeletedcontaining all translations of the model, including those in trash if your model use SoftDelete trait - A function
translate(string $locale, array $translateAttributes = [])to translate a model in a new locale - A function
getTranslation(string $locale, bool $withDeleted = false)returning the translated model in specified locale or null if it doesn't exist. - A scope
withLocale($locale)on the query
You can override the translatableConfig method of the trait if you want to customize his behavior:
You can override the translateAttributes method of the trait if you want to translate some attributes of the model before saving:
Testing
CS Fixer
Lint your code with Laravel Pint using:
Licence
This package is under GNU Affero General Public License v3 or (at your option) any later version.
All versions of laravel-translatable with dependencies
laravel-lang/locales Version ^2.10
laravel/framework Version ^10.0 | ^11.0 | ^12.0 | ^13.0