<?php

namespace Futage\Show\Http\Controllers;

use App\Http\Controllers\PublicController as BaseController;
use Futage\Show\Interfaces\ShowRepositoryInterface;

class ShowPublicController extends BaseController
{
    // use ShowWorkflow;

    /**
     * Constructor.
     *
     * @param type \Futage\Show\Interfaces\ShowRepositoryInterface $show
     *
     * @return type
     */
    public function __construct(ShowRepositoryInterface $show)
    {
        $this->repository = $show;
        parent::__construct();
    }

    /**
     * Show show's list.
     *
     * @param string $slug
     *
     * @return response
     */
    protected function index()
    {
        $shows = $this->repository
        ->pushCriteria(app('Litepie\Repository\Criteria\RequestCriteria'))
        ->scopeQuery(function($query){
            return $query->orderBy('id','DESC');
        })->paginate();


        return $this->response->title(trans('$show::$show.names'))
            ->view('$show::public.show.index')
            ->data(compact('$shows'))
            ->output();
    }

    /**
     * Show show's list based on a type.
     *
     * @param string $slug
     *
     * @return response
     */
    protected function list($type = null)
    {
        $shows = $this->repository
        ->pushCriteria(app('Litepie\Repository\Criteria\RequestCriteria'))
        ->scopeQuery(function($query){
            return $query->orderBy('id','DESC');
        })->paginate();


        return $this->response->title(trans('$show::$show.names'))
            ->view('$show::public.show.index')
            ->data(compact('$shows'))
            ->output();
    }

    /**
     * Show show.
     *
     * @param string $slug
     *
     * @return response
     */
    protected function show($slug)
    {
        $show = $this->repository->scopeQuery(function($query) use ($slug) {
            return $query->orderBy('id','DESC')
                         ->where('slug', $slug);
        })->first(['*']);

        return $this->response->title($$show->name . trans('$show::$show.name'))
            ->view('$show::public.show.show')
            ->data(compact('$show'))
            ->output();
    }

}