/** * Single content entry * @param int|string $id * @param string $channel * @return View */ public function entry($id = null) { Profiler::start('FINDER - ENTRY'); // Find entry by slug or ID if (is_numeric($id)) { if ($this->channel) { $entry = $this->entryRepository->findPublished((int) $id, $this->channel->resource); } else { $entry = $this->entryRepository->findPublished((int) $id); } } else { if ($this->channel) { $entry = $this->entryRepository->findPublishedBySlug($id, $this->channel->resource); } else { $entry = $this->entryRepository->findPublishedBySlug($id); } } // Abort if not found if (!$entry) { \App::abort(404, 'Entry not found'); } // Share to view View::share('entry', $entry); // Views that we need to search for $views = array(str_replace("-", "_", $entry->slug), $this->channel->resource . '_entry', $this->channel->resource . '_' . $this->channel->resource_singular, $this->channel->resource_singular . '_' . str_replace("-", "_", $entry->slug), $this->channel->resource_singular, 'entry', 'index'); // Does the entry have a custom view setup, add as first choice if ($entry->template) { array_unshift($views, $entry->template); } Profiler::end('FINDER - ENTRY'); // The view return $this->render($views); }