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/switch4u.komma.nl/app/Faq/FaqController.php
<?php

namespace App\Faq;

use App\Base\Controller;
use App\Buttons\Models\Button;
use App\Pages\Models\Page;
use App\Faq\Models\Faq;
use App\Servicepoints\Models\Servicepoint;
use Komma\KMS\Components\ComponentService;

class FaqController extends Controller
{
    private $faqService;

    public function __construct(FaqService $faqService)
    {
        parent::__construct();
        $this->faqService = $faqService;
    }

    /**
     * @return \Illuminate\Contracts\View\View
     */
    public function index()
    {
        $page = $this->links->faq->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($page->translation);

        $this->pageService->setSharableVariables($page->servicepoint_id, $page->servicepoint_button_id, $page->servicepoint_heading);

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

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

        $questions = $this->faqService->getAllFaq();

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

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

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

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

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

        $this->pageService->setSharableVariables($faqModel->servicepoint_id, $faqModel->servicepoint_button_id, $faqModel->servicepoint_heading);

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

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

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




}