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/sdo-schoonmaak.komma.pro/app/KommaApp/Vacancies/VacancyController.php
<?php

namespace App\KommaApp\Vacancies;

use App\Http\Controllers\Controller;
use App\KommaApp\Vacancies\Models\Vacancy;

class VacancyController extends Controller
{
    private $pagePrefix = 'pages.vacancies.';
    private $vacancyService;

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

    /**
     * @return \Illuminate\Contracts\View\View
     */
    public function index()
    {
        $page = $this->pageService->getPageByCodeName('vacancies');
        $otherLanguageRoutes = $this->languageService->getOtherLanguagesRoutes($page);

        $vacancies = $this->vacancyService->getAllVacancies(true, 20);
        $vacancies->withPath('/' . $this->links->vacancies->route);

        // Decode the dynamic content
        $page->translation = $this->decodeDynamicContent( $page->translation );

        // Return view
        return \View::make($this->baseViewPath.$this->pagePrefix.'index',[
            'page' => $page,
            'links' => $this->links,
            'otherLanguages' => $otherLanguageRoutes,
            'vacancies' => $vacancies,
        ]);
    }

    /**
     * @return \Illuminate\Contracts\View\View
     */
    public function filters()
    {
        $filters = request('filters');
        dd('customize filter function in VacancyController');

//        if (sizeof($filters) != 1) {
//            throw abort(404);
//        }
//        $categoryName = $filters[0];
//
//        // Check if category exist else trow 404
//        if ( ! $category = VacancyCategoryTranslation::where('slug', $categoryName)
//            ->with('translatable')
//            ->first()) {
//            throw abort(404);
//        }
//
//        $page = $this->pageService->getPageByCodeName('blog');
//        $otherLanguageRoutes = $this->languageService->getOtherLanguagesRoutes($page);
//
//        //Get vacancies through the category
//        $vacancies = $category->translatable->vacancies()->paginate(8);
//        $vacancies->withPath('/' . $this->links->blog->route . '/' . $category->slug);
//
//
//        // Return view
//        return \View::make($this->baseViewPath.$this->pagePrefix.'index',[
//            'page' => $page,
//            'links' => $this->links,
//            'otherLanguages' => $otherLanguageRoutes,
//            'vacancies' => $vacancies,
//        ]);
    }

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

        $page = $this->pageService->getPageByCodeName('vacancies');
        $otherLanguageRoutes = $this->languageService->getOtherLanguagesRoutes($page, $vacancy);

        // Load all Vacancies
        $vacancies = $this->vacancyService->getAllVacancies();

        // Decode the dynamic content
        $vacancy->translation = $this->decodeDynamicContent( $vacancy->translation );

        // Return view
        return \View::make($this->baseViewPath.$this->pagePrefix.'show',[
            'page' => $page,
            'vacancy' => $vacancy,
            'links' => $this->links,
            'vacancies' => $vacancies,
            'otherLanguages' => $otherLanguageRoutes,
        ]);
    }

}