/** * Initialize dependencies * @param TermRepositoryInterface $termRepository * @param TaxonomyRepositoryInterface $taxonomyRepository */ public function __construct(TermRepositoryInterface $termRepository, TaxonomyRepositoryInterface $taxonomyRepository) { $this->termRepository = $termRepository; $this->taxonomyRepository = $taxonomyRepository; $this->taxonomy = $this->taxonomyRepository->find(Request::segment(3)); View::share('taxonomy', $this->taxonomy); }
/** * Save all terms for entry * @param integer $entryId * @param mixed $data * @return mixed */ public function saveAllForEntry($entryId, $data) { $taxonomies = array_get($data, 'taxonomy-terms'); if ($taxonomies) { foreach ($taxonomies as $taxonomy => $terms) { $taxonomy = $this->taxonomies->find($taxonomy); if ($taxonomy) { if ($taxonomy->type == 'tags') { $this->saveTags($entryId, $taxonomy, $terms); } else { $this->saveCategories($entryId, $taxonomy, $terms); } } } } }