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