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/netwerkbrabant/netwerkbrabant.nl/app/KommaApp/Companies/CompanyController.php
<?php

namespace App\KommaApp\Companies;

use App\Http\Controllers\Controller;
use App\KommaApp\Companies\Models\Company;

class CompanyController extends Controller
{
    private $modelPrefix = 'pages.companies.';

    public function index()
    {
        $page = $this->pageService->getPageByCodeName('companies');
        $otherLanguageRoutes = $this->languageService->getOtherLanguagesRoutes($page);

        $page->translation = $this->decodeDynamicContent( $page->translation );

        /** @var CompanyService $companyService */
        $companyService = \App::make(CompanyService::class);
        $companies = $companyService->getAllCompanies();

        $categories = $companyService->getUsedCategories($companies);
        $regions = $companyService->getUsedRegions($companies);

        // Return view
        return \View::make($this->baseViewPath.$this->modelPrefix.'index',[
            'page' => $page,
            'otherLanguages' => $otherLanguageRoutes,
            'companies' => $companies,
            'categories' => $categories,
            'regions' => $regions,
        ]);

    }

    /**
     * @param Company $company
     * @return \Illuminate\Contracts\View\View
     */
    public function show(Company $company)
    {
        // If inactive show 404
        if(!$company->active) \App::abort(404);

        // Load translation by eager loading
        $company->load( 'impression', 'users', 'users.images', 'latestArticles', 'latestArticles.magazines', 'latestArticles.translation', 'latestArticles.images');

        $page = $this->pageService->getPageByCodeName('companies');

        // Return view
        return \View::make($this->baseViewPath.$this->modelPrefix.'show',[
            'company' => $company,
            'page' => $page,
        ]);
    }

}