public function run()
 {
     $categories = [['product', ['pt' => 'rodas', 'en' => 'wheels', 'es' => 'ruedas'], 0], ['product', ['pt' => 'estrada', 'en' => 'road', 'es' => 'carretera'], 1], ['news', ['pt' => 'geral', 'en' => 'main', 'es' => 'general'], 0], ['spec', ['pt' => 'tecnologias', 'en' => 'technologies', 'es' => 'tecnologias'], 0]];
     foreach ($categories as $category) {
         $c = new Category();
         $c->parent_id = $category[2];
         $c->type = $category[0];
         $c->save();
         foreach ($category[1] as $lang => $value) {
             $lang_id = Lang::whereIso($lang)->first()->id;
             $t = new Translation();
             $t->lang_id = $lang_id;
             $t->table = 'categories';
             $t->table_id = $c->id;
             $t->value = $value;
             $t->save();
         }
     }
 }
 /**
  * Update translation with key and value
  *
  * @param $lang
  * @param $table
  * @param $id
  * @param $value
  * @param $key
  * @return mixed
  */
 public function updateKeyValue($lang, $table, $id, $value, $key)
 {
     $transaltion = Translation::where('lang_id', $lang)->where('table', $table)->where('table_id', $id)->first();
     $transaltion->value = $value;
     $transaltion->key = strtolower($key);
     return $transaltion->save();
 }
Ejemplo n.º 3
0
 public function getTitleAttribute()
 {
     $lang = Lang::whereIso(\App::getLocale())->first();
     return Translation::where('lang_id', $lang->id)->where('table', $this->table)->where('table_id', $this->id)->first()->key;
 }
Ejemplo n.º 4
0
 /**
  * Return the description of spec in multiple langs
  * @return mixed
  */
 public function getTranslationAttribute()
 {
     return Translation::where('table', $this->table)->where('table_id', $this->id)->get();
 }