HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/csb.komma.pro/app/Vacancies/VacancyController.php
<?php

namespace App\Vacancies;

use App\Base\Controller;
use App\Components\ComponentService;
use App\Vacancies\Models\Vacancy;

final class VacancyController extends Controller
{
    private $vacancieservice;
    private $vacancyPaginationKey = 'vacancyPagination';

    public function __construct(VacancyService $vacancieservice)
    {
        parent::__construct();
        $this->vacancieservice = $vacancieservice;
    }

    /**
     * @return \Illuminate\Contracts\View\View
     */
    public function index()
    {
        $page = $this->links->vacancies->node;

        $vacancies = $this->vacancieservice->getVacanciesPaginated();
        $vacancies->withPath($this->links->vacancies->route);

        $componentService = app(ComponentService::class);
        $components = $componentService->getViewComponents($page->translation);

        $this->keepTrackOfPagination($this->vacancyPaginationKey);

        // Return view
        return view('templates.vacancies_index',[
            'page' => $page,
            'links' => $this->links,
            'vacancies' => $vacancies,
            'components' => $components,
        ]);
    }


    /**
     * @param Vacancy $vacancy
     * @return \Illuminate\Contracts\View\View
     */
    public function show(Vacancy $vacancy)
    {
        $vacancy->load('translation','translations', 'site');

        $componentService = app(ComponentService::class);
        $components = $componentService->getViewComponents($vacancy->translation);

        // Create previous route for better navigation UX
        $previousRoute = $this->createPreviousRoute($this->vacancyPaginationKey, $this->links->vacancies->route);

        // Make language menu for given page
        $page = $this->links->vacancies->node;

        // Return view
        return view('templates.vacancies_show',[
            'page' => $page,
            'components' => $components,
            'vacancy' => $vacancy,
            'links' => $this->links,
            'previousRoute' => $previousRoute,
        ]);
    }

}