protected function translateAndSave(Collection $elements, Languages $lang, ProgressBar $progress)
    {
        foreach ($elements as $element) {
            $model = $element->translation()->getModel()->firstOrNew(['lang_id' => $lang->id, 'log_id' => $element->id]);
            try {
                $translated  = $element->translated($lang->code);
                $model->raw  = strip_tags($translated);
                $model->text = $translated;
                $model->save();
            } catch (Exception $ex) {
                $this->error($ex->getMessage());
                Log::alert($ex);
                continue;
            }
            $progress->advance();
        }
        return;
    }
protected function translateAndSave(Collection $elements, Languages $lang, ProgressBar $progress)
    {
        foreach ($elements as $element) {
            $model = $element->translation()->getModel()->firstOrNew(['lang_id' => $lang->id, 'log_id' => $element->id]);
            try {
                $translated  = $element->translated($lang->code);
                $model->raw  = strip_tags($translated);
                $model->text = $translated;
                $model->save();
            } catch (Exception $ex) {
                $this->error($ex->getMessage());
                Log::alert($ex);
                continue;
            }
            $progress->advance();
        }
        return;
    }
protected function translateAndSave ( Collection $ elements , Languages $ lang , ProgressBar $ progress ) { foreach ( $ elements as $ element ) { $ model = $ element -> translation ( ) -> getModel ( ) -> firstOrNew ( [ 'lang_id' => $ lang -> id , 'log_id' => $ element -> id ] ) ; try { $ translated = $ element -> translated ( $ lang -> code ) ; $ model -> raw = strip_tags ( $ translated ) ; $ model -> text = $ translated ; $ model -> save ( ) ; } catch ( Exception $ ex ) { $ this -> error ( $ ex -> getMessage ( ) ) ; Log :: alert ( $ ex ) ; continue ; } $ progress -> advance ( ) ; } return ; }
Translates and saves log

@param Collection $elements
@param Languages $lang
@param ProgressBar $progress
@return void
Translates and saves log