anekdotes/polyglot

Abstract model that eases the localization of Illuminate model.

1.1.1 2016-10-14 13:19 UTC

This package is auto-updated.

Last update: 2024-04-13 02:29:52 UTC


README

Latest Stable Version Build Status codecov.io StyleCI License Total Downloads

Abstract model that eases the localization of Illuminate model.

Installation

Install via composer into your project:

composer require anekdotes/polyglot

Usage

Extends the model you wish to translate with the class

class Test extends TranslatedModel

Add the desired translated columns to the polyglot array (locale has to be there)

protected $polyglot = ['locale', 'title', 'description', 'slug'];

Don't forget to also add the translated columns to the fillable array

protected $fillable = ['rank', 'locale', 'title', 'description', 'slug'];

Make a new file preferably Lang.php and extends Illuminate Model

class TestLang extends Model

Add the translated columns to the fillable array and set timestamps to false

protected $fillable = ['locale', 'title', 'description', 'slug'];

public $timestamps = false;