protected function cacheTerm($term_id)
    {
        $term = TermContainer::with('translations')->find($term_id);

        if (!$term || !count($term->translations)) {
            return false;
        }

        $translations = [];
        foreach ($term->translations as $t) {
            $translations[$t->language_id] = $t;
        }

        $first = $term->translations[0];

        $final_term = [
            'term_id' => $term_id,
            'vocabulary_id' => $term->vocabulary_id,
            'type' => $term->type,
        ];

        if (T::isTranslatable($term->vocabulary_id)) {
            foreach (I18N::languages() as $lang => $l) {
                if (array_key_exists($l['id'], $translations)) {
                    $term = $translations[$l['id']];
                } else {
                    $term = new TermData();
                    $term->term_id = $term_id;
                    $term->language_id = $l['id'];
                    $term->title = $first->title;
                    $term->description = $first->description;
                    $term->translated = false;
                }

                $final_term['lang_' . $lang] = $term;
            }
        } else {
            $final_term['has_translations'] = false;
            $final_term['lang'] = $first;
        }

        $this->cache->put(self::$cacheKey . $term_id, $final_term, 60 * 0);

        return $final_term;
    }
protected function cacheTerm($term_id)
    {
        $term = TermContainer::with('translations')->find($term_id);

        if (!$term || !count($term->translations)) {
            return false;
        }

        $translations = [];
        foreach ($term->translations as $t) {
            $translations[$t->language_id] = $t;
        }

        $first = $term->translations[0];

        $final_term = [
            'term_id' => $term_id,
            'vocabulary_id' => $term->vocabulary_id,
            'type' => $term->type,
        ];

        if (T::isTranslatable($term->vocabulary_id)) {
            foreach (I18N::languages() as $lang => $l) {
                if (array_key_exists($l['id'], $translations)) {
                    $term = $translations[$l['id']];
                } else {
                    $term = new TermData();
                    $term->term_id = $term_id;
                    $term->language_id = $l['id'];
                    $term->title = $first->title;
                    $term->description = $first->description;
                    $term->translated = false;
                }

                $final_term['lang_' . $lang] = $term;
            }
        } else {
            $final_term['has_translations'] = false;
            $final_term['lang'] = $first;
        }

        $this->cache->put(self::$cacheKey . $term_id, $final_term, 60 * 0);

        return $final_term;
    }
protected function cacheTerm ( $ term_id ) { $ term = TermContainer :: with ( 'translations' ) -> find ( $ term_id ) ; if ( ! $ term || ! count ( $ term -> translations ) ) { return false ; } $ translations = [ ] ; foreach ( $ term -> translations as $ t ) { $ translations [ $ t -> language_id ] = $ t ; } $ first = $ term -> translations [ 0 ] ; $ final_term = [ 'term_id' => $ term_id , 'vocabulary_id' => $ term -> vocabulary_id , 'type' => $ term -> type , ] ; if ( T :: isTranslatable ( $ term -> vocabulary_id ) ) { foreach ( I18N :: languages ( ) as $ lang => $ l ) { if ( array_key_exists ( $ l [ 'id' ] , $ translations ) ) { $ term = $ translations [ $ l [ 'id' ] ] ; } else { $ term = new TermData ( ) ; $ term -> term_id = $ term_id ; $ term -> language_id = $ l [ 'id' ] ; $ term -> title = $ first -> title ; $ term -> description = $ first -> description ; $ term -> translated = false ; } $ final_term [ 'lang_' . $ lang ] = $ term ; } } else { $ final_term [ 'has_translations' ] = false ; $ final_term [ 'lang' ] = $ first ; } $ this -> cache -> put ( self :: $ cacheKey . $ term_id , $ final_term , 60 * 0 ) ; return $ final_term ; }
Puts the term in the cache and returns it for usage

@param  int $term_id
@return array
Puts the term in the cache and returns it for usage