File: D:/HostingSpaces/SBogers10/netwerkbrabant.komma.pro/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,
]);
}
}