<?php namespace Tag\Tag\Http\Controllers; use App\Http\Controllers\PublicController as CMSPublicController; use Tag\Tag\Interfaces\TagRepositoryInterface; class TagPublicController extends CMSPublicController { /** * Constructor. * * @param type \Tag\Tag\Interfaces\TagRepositoryInterface $tag * * @return type */ public function __construct(TagRepositoryInterface $tag) { $this->repository = $tag; parent::__construct(); } /** * Show tag's list. * * @param string $slug * * @return response */ protected function index() { $tags = $this->repository->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->paginate(); return $this->theme->of('tag::public.tag.index', compact('tags'))->render(); } /** * Show tag. * * @param string $slug * * @return response */ protected function show($slug) { $tag = $this->repository->scopeQuery(function($query) use ($slug) { return $query->orderBy('id','DESC') ->where('slug', $slug); })->first(['*']); return $this->theme->of('tag::public.tag.show', compact('tag'))->render(); } }