/** * Show a specific term * @param integer $id * @return Response */ public function show($id) { // Prepare $terms = array(); $ids = explode(",", $id); foreach ($ids as $id) { if ($term = $this->terms->find($id)) { $terms[] = $term->toArray(); } } if ($term) { return Response::json($terms); } }
/** * Update exiting content entry * @param integer $id * @param array $data * @return boolean */ public function update($id, $data = array()) { // First validate the input if ($this->validation->passes($data)) { // Set the data $entry = Entry::find($id); $entry->fill(array('title' => array_get($data, 'title'), 'body' => array_get($data, 'body'), 'channel' => array_get($data, 'channel'), 'status' => $this->inputStatus($data), 'meta_title' => array_get($data, 'meta_title'), 'meta_keywords' => array_get($data, 'meta_keywords'), 'meta_description' => array_get($data, 'meta_description'))); // Slug if ($slug = array_get($data, 'slug') and $slug != $entry->slug) { $entry->slug = Str::slug($slug); } // Template $entry->template = str_replace("-", "_", Str::slug(array_get($data, 'template'))); // Save custom fields $this->fields->saveAllForEntry($id, $data); // Also save taxonomies $this->terms->saveAllForEntry($id, $data); // Log it Log::debug('[KRUSTR] [ENTRYREPOSITORY] Entry [' . $id . '] was updated.'); return $entry->save(); } // Set errors $this->errors = $this->validation->errors(); return false; }
/** * Collection of entries in taxonomy by term * @param string $term * @return View */ public function entryTaxonomyCollection($term) { Profiler::start('FINDER - ENTRY TAXONOMY COLLECTION'); // First get taxonomy $taxonomy = app('krustr.taxonomies')->findBySlug(Request::segment(2)); if ($taxonomy) { $term = $this->termRepository->findBySlug($term); if ($term) { $entries = $this->entryRepository->allPublishedByTerm($term->id, $this->channel->resource); } else { return App::abort(404); } View::share('term', $term); } else { return App::abort(404); } // Share content View::share('entries', $entries); View::share('pagination', $this->entryRepository->pagination()); View::share('taxonomy', $taxonomy); // Views that we need to search for $views = array($this->channel->name . '_' . $taxonomy->name_singular, $this->channel->name . '_taxonomy', $taxonomy->name_singular, 'taxonomy_' . $taxonomy->name_singular, $this->channel->resource_singular . '_collection', $this->channel->resource, $this->channel->resource . '_collection', 'taxonomy', 'collection', 'index'); Profiler::end('FINDER - ENTRY TAXONOMY COLLECTION'); // The view return $this->render($views); }