File: D:/HostingSpaces/Eurotools/euro-tools.nl/app/KommaApp/Pages/PageController.php
<?php
namespace App\KommaApp\Pages;
use App\Http\Controllers\Controller;
use App\KommaApp\Auth\RegisterController;
use App\KommaApp\Pages\Models\Page;
use App\KommaApp\Shop\Cart\ShoppingCartController;
use App\KommaApp\Shop\Catalog\Kms\CatalogService;
use Symfony\Component\HttpFoundation\Request;
class PageController extends Controller
{
private $pagePrefix = 'pages.';
/**
* @param Page $page
* @return \Illuminate\Contracts\View\View
*/
public function show(Page $page, CatalogService $catalogService, Request $request)
{
// Load translation by eager loading
$page->load( 'translation');
// Check if given Page belongs to the set site
if($page->site_id != \App::getSite()->id) throw abort(404);
$this->pageService->generateBreadcrumbTree($page, $this->links);
// Get the route in other languages for menu and meta title
$otherLanguageRoutes = $this->languageService->getOtherLanguagesRoutes($page);
$page->translation = $this->decodeDynamicContent( $page->translation );
$view = $this->baseViewPath.$this->pagePrefix. $page->code_name;
if( ! \View::exists($view)) $view = $this->baseViewPath.$this->pagePrefix. 'default';
$featuredProducts = null;
if($page->code_name == 'home') {
$featuredProducts = $catalogService->getFeaturedProducts()->take(80);
}
if($page->code_name == 'search') {
return \App::make(CatalogService::class)->search($request);
}
// if($page->code_name == 'shoppingcart') {
// return \App::call('App\KommaApp\Shop\Cart\ShoppingCartController@index');
// }
if($page->code_name == 'register') {
return \App::make(RegisterController::class)->showRegistrationForm();
}
// Return view
return \View::make($view,[
'page' => $page,
'links' => $this->links,
'categories' => $this->categories,
'featuredProducts' => $featuredProducts,
'otherLanguages' => $otherLanguageRoutes,
]);
}
}