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/SBogers60/royalforkliftbenelux.com/app/Komma/Projects/ProjectController.php
<?php

/**
 * Short description for the file.
 *
 * @author      Komma <support@komma.pro>
 * @copyright   (c) 2012-2015, Komma Mediadesign
 */

namespace Komma\Projects;

use Illuminate\Support\Collection;
use Komma\Blocks\BlockService;
use Komma\Images\ImageService;
use Komma\LanguageService;
use Komma\Pages\PageService;

class ProjectController extends \BaseController
{

    protected $pageService;
    protected $projectService;
    public $languageService;

    public function __construct(
        PageService $pageService,
        ProjectService $projectService,
        LanguageService $languageService
    ) {
        parent::__construct();
        $this->pageService = $pageService;
        $this->projectService = $projectService;
        $this->languageService = $languageService;
    }

    //Project index page
    public function index()
    {
        //Check if language matches the url before loading content
        $this->languageService->checkRouteWithSetLanguage();

        //get content of page and get all page links
        $page = $this->pageService->getPageByCodeName('trucks');
        $truckPages = $this->pageService->getChildrenPages($page);

        $links = $this->pageService->getAllRoutes();

        return \View::make('layouts.pages.projects.index')
            ->with('page', $page)
            ->with('links', $links)
            ->with('truckPages', $truckPages);
    }

    public function category($id){

        //get content of page
        $page = $this->pageService->getPageContent($id);
        $links = $this->pageService->getAllRoutes();

        $truckPages = $this->pageService->getChildrenPages($links->trucks->page);

        $overviewPage = $this->pageService->getPageByCodeName('trucks');

        $page->translation->meta_title .= ' | ' . $overviewPage->translation->meta_title;

        //Get all projects
        $projects = $this->projectService->getProjectsWhere('project_type', $page->id);

        return \View::make('layouts.pages.projects.category')
            ->with('page', $page)
            ->with('links', $links)
            ->with('truckPages', $truckPages)
            ->with('projects', $projects);

    }

    //Project index page
    public function projectOverview(){
        //Check if language matches the url before loading content
        $this->languageService->checkRouteWithSetLanguage();

        //get content of page and get all page links
        $page = $this->pageService->getPageByCodeName('machines');
        $links = $this->pageService->getAllRoutes();

        //Get all projects
        $projects = $this->projectService->getProjectsWhere('project_type', 0);

        return \View::make('layouts.pages.projects.overview')
            ->with('page', $page)
            ->with('links', $links)
            ->with('projects', $projects);

    }

    public function show($projectId)
    {
        //Check if language matches the url before loading content
        $this->languageService->checkRouteWithSetLanguage();

        $page = $this->pageService->getPageByCodeName('trucks');
        $links = $this->pageService->getAllRoutes();

        //Get active project
        $page->project = $this->projectService->getProject($projectId);

        $pageMetaTitle = $page->translation->meta_title;

        if($page->project->project_type === 0) {
            $typePage = $this->pageService->getPageByCodeName('machines');
            $pageMetaTitle = $typePage->translation->meta_title;
        }
        else{
            $typePage = $this->pageService->getPageContent($page->project->project_type);
        }
        $page->returnRoute = $typePage->translation->route->route;


        //Rename meta description
        $page->translation->meta_title = $page->project->translation->name . ' | ' . $pageMetaTitle;
        $page->translation->meta_description = $page->project->meta_description;

        return \View::make('layouts.pages.projects.show')
            ->with('page', $page)
            ->with('links', $links);
    }

}