<?php

namespace Ads\Channel\Http\Controllers;

use App\Http\Controllers\PublicController as CMSPublicController;
use Ads\Channel\Interfaces\ChannelRepositoryInterface;

class ChannelPublicController extends CMSPublicController
{
    /**
     * Constructor.
     *
     * @param type \Ads\Channel\Interfaces\ChannelRepositoryInterface $channel
     *
     * @return type
     */
    public function __construct(ChannelRepositoryInterface $channel)
    {
        $this->model = $channel;
        parent::__construct();
    }

    /**
     * Show channel's list.
     *
     * @param string $slug
     *
     * @return response
     */
    protected function index()
    {
        $channels = $this->model->all();

        return $this->theme->of('channel::public.channel.index', compact('channels'))->render();
    }

    /**
     * Show channel.
     *
     * @param string $slug
     *
     * @return response
     */
    protected function show($slug)
    {
        $channel = $this->model->findBySlug($slug);

        return $this->theme->of('channel::public.channel.show', compact('channel'))->render();
    }
}