<?php

namespace Ori\UniMessage\Http\Controllers;

use App\Http\Controllers\PublicController as CMSPublicController;
use Ori\UniMessage\Interfaces\UniMessageRepositoryInterface;

class UniMessagePublicController extends CMSPublicController
{
    /**
     * Constructor.
     *
     * @param type \Ori\UniMessage\Interfaces\UniMessageRepositoryInterface $uni_message
     *
     * @return type
     */
    public function __construct(UniMessageRepositoryInterface $uni_message)
    {
        $this->model = $uni_message;
        parent::__construct();
    }

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

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

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

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