Skip to content

netdown/laravel-translatable

This branch is 507 commits behind Astrotomic/laravel-translatable:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

807882a · Jul 31, 2019
Jul 15, 2019
Jul 24, 2019
Jul 16, 2019
Jul 31, 2019
Jul 30, 2019
Jun 20, 2019
Jun 18, 2019
Feb 7, 2016
Jun 20, 2019
Jun 19, 2019
May 13, 2018
Jun 19, 2019
Jun 19, 2019
Jun 18, 2019
Jul 16, 2019
Jul 16, 2019
Jun 20, 2019
Feb 27, 2019

Repository files navigation

Introduction

Total Downloads CircleCI StyleCI ScrutinizerCI Code Climate Code Coverage Latest Version MIT License GitBook

Laravel Translatable

If you want to store translations of your models into the database, this package is for you.

This is a Laravel package for translatable models. Its goal is to remove the complexity in retrieving and storing multilingual model instances. With this package you write less code, as the translations are being fetched/saved when you fetch/save your instance.

The full documentation can be found at GitBook.

Quick Example

Getting translated attributes

$post = Post::first();
echo $post->translate('en')->title; // My first post

App::setLocale('en');
echo $post->title; // My first post

App::setLocale('de');
echo $post->title; // Mein erster Post

Saving translated attributes

$post = Post::first();
echo $post->translate('en')->title; // My first post

$post->translate('en')->title = 'My cool post';
$post->save();

$post = Post::first();
echo $post->translate('en')->title; // My cool post

Filling multiple translations

$data = [
  'author' => 'Gummibeer',
  'en' => ['title' => 'My first post'],
  'fr' => ['title' => 'Mon premier post'],
];
$post = Post::create($data);

echo $post->translate('fr')->title; // Mon premier post

Tutorials

Versions

Package Laravel PHP
v11.1 5.6.* | 5.7.* | 5.8.* >=7.1.3
v11.0 5.6.* | 5.7.* | 5.8.* >=7.1.3

About

A Laravel package for multilingual models

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%