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