<?php

namespace Lavalite\Career\Http\Controllers;

use App\Http\Controllers\PublicController as CMSPublicController;
use Lavalite\Career\Interfaces\JobRepositoryInterface;

class JobPublicController extends CMSPublicController
{
    /**
     * Constructor.
     *
     * @param type \Lavalite\Job\Interfaces\JobRepositoryInterface $job
     *
     * @return type
     */
    public function __construct(JobRepositoryInterface $job)
    {
        $this->model = $job;
        parent::__construct();
    }

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

        return $this->theme->of('career::public.job.index', compact('jobs'))->render();
    }

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

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