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,
]);
}
}