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 2 fields : locale and locale_parent_id.
Requirements
- Laravel >= 10.0
- PHP >= 8.2
NOTE: These instructions are for Laravel >= 10.0 and PHP >= 8.2 If you are using prior version, please see the previous version's docs.
Installation
You can install the package via composer:
Usage
Migrations
Eloquent Model Trait
This trait add :
- A relation
translations
containing all translations of the model - A relation
translationsWithDeleted
containing 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 query
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
illuminate/database Version ^10.0|^11.0
illuminate/support Version ^10.0|^11.0