New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

mammut-alex/polyglot

Translate model column in laravel
1,929 2
Install
composer require mammut-alex/polyglot
Latest Version:0.2.0
PHP:>=5.6.4
License:MIT
Last Updated:Sep 20, 2018
Links: GitHub  ·  Packagist
Maintainer: MammutCris

Polyglot

Build Status Total Downloads Latest Stable Version License Code Climate StyleCI

Installation

Require this package in your composer.json and update composer.

"mammut-alex/polyglot": "0.2.*"

or composer require mammut-alex/polyglot

Documentation

Translator works with a database, it looks for a prefix code language

Here is an example Migration

    $table->string('name_en');
    $table->string('name_uk');
    $table->string('name_ru');

To use polyglot, connect it to your model and use feature for translation.

namespace App;

use Illuminate\Database\Eloquent\Model;
use MammutAlex\Polyglot\Polyglot;

class YouModel extends Model
{
	use Polyglot;
	
	public function name()
    	{
    		return $this->translation('name');
    	}
    ...

The function will return the translation in the selected language user

An example of the use in blade:

<h1>{{$model->name()}}</h1>

See more example in tests, documentation being developed

Related Packages

laragear/meta-model

Let other developers customize your package model and migrations

2,068,438 1
tusimo/embed-relation

a relation for laravel

10,959 3
zae/lara-press

A set of models to use with Laravel's Eloquent to query a Wordpress database.

4,580 4
kitar/laravel-dynamodb

A DynamoDB based Eloquent model and Query builder for Laravel.

882,026 193
pdphilip/opensearch

An OpenSearch implementation of Laravel's Eloquent ORM

480,696 0

Version History

Version Released PHP License
0.2.0 >=5.6.4 MIT
0.1.6 >=5.6.4 MIT
0.1.5 >=5.6.4 MIT
0.1.4 >=5.6.4 MIT
0.1.3 >=5.6.4 MIT