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/ASmits/kemi.nl/app/KommaApp/Projects/ProjectController.php
<?php

namespace App\KommaApp\Projects;

use App\Http\Controllers\Controller;
use App\KommaApp\Projects\Models\Project;

class ProjectController extends Controller
{
    private $pagePrefix = 'pages.projects.';
    private $projectService;

    public function __construct(ProjectService $projectService)
    {
        parent::__construct();
        $this->projectService = $projectService;


        \View::share('showHexagon', true);
    }

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

        $projects = $this->projectService->getAllProjects(true);

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

    /**
     * @return \Illuminate\Contracts\View\View
     */
    public function filters()
    {
        // This site doesn't use filters so throw 404 error
        abort(404);
        $filters = request('filters');
        var_dump('Filter projects with these filters:');

        $page = $this->pageService->getPageByCodeName('projects');
        $otherLanguageRoutes = $this->languageService->getOtherLanguagesRoutes($page);

        $projects = $this->projectService->getAllProjects(true);


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


    /**
     * @param Page $page
     * @return \Illuminate\Contracts\View\View
     */
    public function show(Project $project)
    {
        $project->load('translation');

        $page = $this->pageService->getPageByCodeName('projects');
        $page->translation = $this->decodeDynamicContent( $page->translation );
        $project->translation = $this->decodeDynamicContent( $project->translation );
        $otherLanguageRoutes = $this->languageService->getOtherLanguagesRoutes($page, $project);

        if(sizeof($project->translation->description) != 0){
            // Shift the first dynamic block because that has custom styling
            $primaryBlock = $project->translation->description[0];
        }
        else{
            $primaryBlock = null;
        }



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

}