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/stempel.komma.pro/app/Komma/Jobs/JobController.php
<?php

namespace App\Komma\Jobs;

use App\Komma\Base\Controller;
use App\Komma\Buttons\Models\Button;
use App\Komma\Buttons\Models\ButtonTranslation;
use App\Komma\Components\ComponentService;
use App\Komma\Pages\Models\Page;
use App\Komma\Jobs\Models\Job;
use App\Komma\Servicepoints\Models\Servicepoint;

class JobController extends Controller
{
    private $jobService;

    public function __construct(JobService $jobService)
    {
        parent::__construct();
        $this->jobService = $jobService;
    }

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

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

        $jobs = $this->jobService->getAllJobs(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.jobs_index',[
            'page' => $page,
            'components' => $components,
            'jobs' => $jobs,
            'links' => $this->links,
            'languageMenu' => $languageMenu,
        ]);
    }

    /**
     * @param Job $service
     * @return \Illuminate\Contracts\View\View
     */
    public function show(Job $job)
    {
        $job->load('translation','translations', 'sites');
        // This checks if the job belongs to the set site
        if(! $job->site == $this->site) throw abort(404);

        $jobs = $this->jobService->getAllJobs();

        $page = $this->links->jobs->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($job->translation);

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

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

        $job->hero = (object)[
            'documents' => $heroDocuments,
            'active' => $job->translation->hero_active,
            'title' => $job->translation->hero_title,
            'description' => $job->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($job->servicepoint_id) ? $job->servicepoint_id : config('site.global_CTA_servicepoint_id'));

        $viewData = [
            'showServicePoint' => $showServicePoint,
            'page' => $page,
            'components' => $components,
            'jobs' => $jobs,
            'job' => $job,
            '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.jobs_show', $viewData);
    }

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

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




}