src/DatabaseLoader.php
public function addTranslation($locale, $group, $key)
    {
        if(!\Config::get('app.debug') || \Config::get('translation-db.minimal')) return;

        // Extract the real key from the translation.
        if (preg_match("/^{$group}\.(.*?)$/sm", $key, $match)) {
            $name = $match[1];
        } else {
            throw new TranslationException('Could not extract key from translation.');
        }

        $item = \DB::table('translations')
            ->where('locale', $locale)
            ->where('group', $group)
            ->where('name', $name)->first();

        $data = compact('locale', 'group', 'name');
        $data = array_merge($data, [
            'viewed_at' => date_create(),
            'updated_at' => date_create(),
        ]);

        if($item === null) {
            $data = array_merge($data, [
                'created_at' => date_create(),
            ]);
            \DB::table('translations')->insert($data);
        } else {
            if($this->_app['config']->get('translation-db.update_viewed_at')) {
                \DB::table('translations')->where('id', $item->id)->update($data);
            }
        }
    }
public function addTranslation($locale, $group, $key)
    {
        if(!\Config::get('app.debug') || \Config::get('translation-db.minimal')) return;

        // Extract the real key from the translation.
        if (preg_match("/^{$group}\.(.*?)$/sm", $key, $match)) {
            $name = $match[1];
        } else {
            throw new TranslationException('Could not extract key from translation.');
        }

        $item = \DB::table('translations')
            ->where('locale', $locale)
            ->where('group', $group)
            ->where('name', $name)->first();

        $data = compact('locale', 'group', 'name');
        $data = array_merge($data, [
            'viewed_at' => date_create(),
            'updated_at' => date_create(),
        ]);

        if($item === null) {
            $data = array_merge($data, [
                'created_at' => date_create(),
            ]);
            \DB::table('translations')->insert($data);
        } else {
            if($this->_app['config']->get('translation-db.update_viewed_at')) {
                \DB::table('translations')->where('id', $item->id)->update($data);
            }
        }
    }
public function addTranslation ( $ locale , $ group , $ key ) { if ( ! \ Config :: get ( 'app.debug' ) || \ Config :: get ( 'translation-db.minimal' ) ) return ; // Extract the real key from the translation. if ( preg_match ( "/^{$group}\.(.*?)$/sm" , $ key , $ match ) ) { $ name = $ match [ 1 ] ; } else { throw new TranslationException ( 'Could not extract key from translation.' ) ; } $ item = \ DB :: table ( 'translations' ) -> where ( 'locale' , $ locale ) -> where ( 'group' , $ group ) -> where ( 'name' , $ name ) -> first ( ) ; $ data = compact ( 'locale' , 'group' , 'name' ) ; $ data = array_merge ( $ data , [ 'viewed_at' => date_create ( ) , 'updated_at' => date_create ( ) , ] ) ; if ( $ item === null ) { $ data = array_merge ( $ data , [ 'created_at' => date_create ( ) , ] ) ; \ DB :: table ( 'translations' ) -> insert ( $ data ) ; } else { if ( $ this -> _app [ 'config' ] -> get ( 'translation-db.update_viewed_at' ) ) { \ DB :: table ( 'translations' ) -> where ( 'id' , $ item -> id ) -> update ( $ data ) ; } } }
Adds a new translation to the database or
updates an existing record if the viewed_at
updates are allowed.

@param string $locale
@param string $group
@param string $name
@return void
Adds a new translation to the database or updates an existing record if the viewed_at updates are allowed .