buntan / translations by aanyszek

Translation trait
9
0
0
Package Data
Maintainer Username: aanyszek
Maintainer Contact: a.anyszek@linux.pl (Artur Anyszek)
Package Create Date: 2016-08-05
Package Last Update: 2016-08-05
Language: PHP
License: MIT
Last Refreshed: 2024-03-24 03:01:14
Package Statistics
Total Downloads: 9
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 0
Total Forks: 0
Total Open Issues: 0

translations

instalation

add to "\config\app.php":

'providers' => [
    ...
    Bunta\Translations\TranslationsServiceProvider::class
    ...
],

add to "\app\SomeModel.php":

...
use \Bunta\Translations\TranslationsTrait;
...
public $translatedAttributes = ['nameVirtualAttributeToTranslate'];
...

run comands

composer du
php artisan optimize 
php artisan vendor:publish
php artisan migrate

Usage

Access to right translate

$model->nameVirtualAttributeToTranslate; 

Access to all translates

@foreach(Config::get('translations.locales') as $lang)
    {!! Form::text("nameVirtualAttributeToTranslate[$lang]",$model->translation('nameVirtualAttributeToTranslate',$lang)) !!}
@endforeach 

save translate

 Model::create($request->all());