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

namespace App\Vacancies;

use App\Base\Controller;
use App\Buttons\Models\Button;
use App\Components\ComponentService;
use App\Pages\Models\Page;
use App\Vacancies\Models\Vacancy;
use App\Servicepoints\Models\Servicepoint;

class VacancyController extends Controller
{
    private $vacancyService;

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

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

        // Make language menu for given page
        $languageMenu = $this->pageService->makeLanguageSwitchForPage($this->links->{$page->code_name}, $this->links->home);

        $vacancies = $this->vacancyService->getAllVacancies(false);

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

        $this->pageService->setSharebleVariables($page->servicepoint_id, $page->cta_button_id, $page->cta_heading);

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

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

        $vacancies = $this->vacancyService->getAllVacancies();

        $page = $this->links->vacancies->node;
        // Make language menu for given page
        $languageMenu = $this->pageService->makeLanguageSwitchForPage($this->links->{$page->code_name}, $this->links->home);

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

        // split the Hero images from the "normal" post images
        list($documents, $heroDocuments) = $vacancy->translation->documents->partition(function ($document) {
            return $document->key == 'Documents-vacancies';
        });
        $vacancy->documents = $documents;

        // fill the page hero object
        $heroButton = Button::where('id', $vacancy->translation->hero_button_id)->with('translation')->first();

        $vacancy->hero = (object)[
            'documents' => $heroDocuments,
            'active' => $vacancy->translation->hero_active,
            'title' => $vacancy->translation->hero_title,
            'description' => $vacancy->translation->hero_description,
            'buttons' => !empty($heroButton) ? $heroButton : null,
        ];

        $discover_more_page_codenames = $page->discoverPages()->get()->map(function(Page $page) {
            return $page->code_name;
        })->toArray();

        $showServicePoint = Servicepoint::find( !empty($vacancy->servicepoint_id) ? $vacancy->servicepoint_id : config('site.global_CTA_servicepoint_id'));

        $viewData = [
            'showServicePoint' => $showServicePoint,
            'page' => $page,
            'components' => $components,
            'vacancies' => $vacancies,
            'vacancy' => $vacancy,
            'links' => $this->links,
            'languageMenu' => $languageMenu,
            'discover_page_codenames' => $discover_more_page_codenames,
        ];

        $this->pageService->setSharebleVariables($page->servicepoint_id, $page->cta_button_id, $page->cta_heading);

        // Return view
        return view('site.templates.vacancies_show', $viewData);
    }

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




}