public function save()
    {
        $attributes = $this->getModifiedAttributes();
        $savings = [];

        foreach ($attributes as $key => $attribute) {
            if ($attribute['exists']) {
                $translation = $this->getTranslationModel($key);
            } else {
                $translation = VoyagerFacade::model('Translation')->where('table_name', $this->model->getTable())
                    ->where('column_name', $key)
                    ->where('foreign_key', $this->model->getKey())
                    ->where('locale', $this->locale)
                    ->first();
            }

            if (is_null($translation)) {
                $translation = VoyagerFacade::model('Translation');
            }

            $translation->fill([
                'table_name'  => $this->model->getTable(),
                'column_name' => $key,
                'foreign_key' => $this->model->getKey(),
                'value'       => $attribute['value'],
                'locale'      => $this->locale,
            ]);

            $savings[] = $translation->save();

            $this->attributes[$key]['locale'] = $this->locale;
            $this->attributes[$key]['exists'] = true;
            $this->attributes[$key]['modified'] = false;
        }

        return in_array(false, $savings);
    }
public function save()
    {
        $attributes = $this->getModifiedAttributes();
        $savings = [];

        foreach ($attributes as $key => $attribute) {
            if ($attribute['exists']) {
                $translation = $this->getTranslationModel($key);
            } else {
                $translation = VoyagerFacade::model('Translation')->where('table_name', $this->model->getTable())
                    ->where('column_name', $key)
                    ->where('foreign_key', $this->model->getKey())
                    ->where('locale', $this->locale)
                    ->first();
            }

            if (is_null($translation)) {
                $translation = VoyagerFacade::model('Translation');
            }

            $translation->fill([
                'table_name'  => $this->model->getTable(),
                'column_name' => $key,
                'foreign_key' => $this->model->getKey(),
                'value'       => $attribute['value'],
                'locale'      => $this->locale,
            ]);

            $savings[] = $translation->save();

            $this->attributes[$key]['locale'] = $this->locale;
            $this->attributes[$key]['exists'] = true;
            $this->attributes[$key]['modified'] = false;
        }

        return in_array(false, $savings);
    }
public function save ( ) { $ attributes = $ this -> getModifiedAttributes ( ) ; $ savings = [ ] ; foreach ( $ attributes as $ key => $ attribute ) { if ( $ attribute [ 'exists' ] ) { $ translation = $ this -> getTranslationModel ( $ key ) ; } else { $ translation = VoyagerFacade :: model ( 'Translation' ) -> where ( 'table_name' , $ this -> model -> getTable ( ) ) -> where ( 'column_name' , $ key ) -> where ( 'foreign_key' , $ this -> model -> getKey ( ) ) -> where ( 'locale' , $ this -> locale ) -> first ( ) ; } if ( is_null ( $ translation ) ) { $ translation = VoyagerFacade :: model ( 'Translation' ) ; } $ translation -> fill ( [ 'table_name' => $ this -> model -> getTable ( ) , 'column_name' => $ key , 'foreign_key' => $ this -> model -> getKey ( ) , 'value' => $ attribute [ 'value' ] , 'locale' => $ this -> locale , ] ) ; $ savings [ ] = $ translation -> save ( ) ; $ this -> attributes [ $ key ] [ 'locale' ] = $ this -> locale ; $ this -> attributes [ $ key ] [ 'exists' ] = true ; $ this -> attributes [ $ key ] [ 'modified' ] = false ; } return in_array ( false , $ savings ) ; }
Save changes made to the translator attributes.

@return bool
Save changes made to the translator attributes .