File: D:/HostingSpaces/SBogers10/farmfun.komma.pro/app/Komma/Pages/PageController.php
<?php
namespace App\Komma\Pages;
use App\Komma\Base\Controller;
use App\Komma\Components\ComponentService;
use App\Komma\Pages\Models\Page;
use App\Komma\Teamleader\TeamleaderApi;
// use App\Komma\Teamleader\TeamleaderApi;
final class PageController extends Controller
{
/**
* @param Page $page
* @return \Illuminate\Contracts\View\View
*/
public function show(Page $page)
{
// // USE THIS TO GET teamleader_department_id AND teamleader_related_user_id FOR NEW LOCATIONS
// $teamleaderApi = new TeamleaderApi();
// // get Teamleader department data
// $departmentResponse = $teamleaderApi->department->list();
// dd($departmentResponse );
//
// // get Teamleader users data
// $userResponse = $teamleaderApi->user->list();
// dd($userResponse );
// Get the page through the set links if translation isnt defined
if (! isset($page->translation)) {
$page = $this->links->{$page->code_name}->node;
}
$componentService = app(ComponentService::class);
$components = $componentService->getViewComponents($page->translation);
// Make language menu for given page
$languageMenu = $this->pageService->makeLanguageSwitchForPage($this->links->{$page->code_name}, $this->links->home);
$view = 'site.templates.'.$page->code_name;
if (! view()->exists($view)) {
$view = 'site.templates.default';
}
if (in_array($page->code_name, ['disclaimer'])) {
$view = 'site.templates.textOnly';
} elseif ($page->code_name === 'page_28') {
$view = 'site.templates.bumperball_reserve';
}
// Return view
return view($view, [
'components' => $components,
'links' => $this->links,
'languageMenu' => $languageMenu,
'page' => $page,
]);
}
public function contest($antw)
{
$page = Page::where('code_name', 'contest')->with('translation')->first();
// Get the page through the set links if translation isnt defined
if (! isset($page->translation)) {
$page = $this->links->{$page->code_name}->node;
}
$componentService = app(ComponentService::class);
$components = $componentService->getViewComponents($page->translation);
// Make language menu for given page
$languageMenu = $this->pageService->makeLanguageSwitchForPage($this->links->{$page->code_name}, $this->links->home);
$view = 'site.templates.'.$page->code_name;
// Return view
return view($view, [
'components' => $components,
'links' => $this->links,
'languageMenu' => $languageMenu,
'page' => $page,
'antw' => $antw,
]);
}
}