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/SBogers10/sportivo.komma.pro/app/Komma/Sports/SportsController.php
<?php


namespace Komma\Sports;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Redirect;
use Komma\Blog\BlogService;
use Komma\Page\PageService;

class SportsController extends Controller
{

    public $data;
    protected $sportsService;
    protected $blogService;
    protected $pageService;

    public function __construct(SportsService $sportsService, BlogService $blogService, PageService $pageService)
    {
        $this->sportsService = $sportsService;
        $this->blogService = $blogService;
        $this->pageService = $pageService;
        $this->data = [
            'socialMeda'      => true,
            'grouplessons'    => $this->sportsService->getGroupLessons(),
            'articleBlock'    => ['header' => 'Recente blog artikelen',
                                  'articles'=> $this->blogService->getLatestBlogItems(2),
                                  'footer'=>'Bekijk alle blog artikelen',
                                  'url'=>'/blog']
        ];
    }

    public function show($slug1 = null, $slug2 = null)
    {
        // Repository:
        $this->data = array_merge($this->data, $this->sportsService->getContent('general'));
        $this->data['slug1'] = $slug1;
        $this->data['slug2'] = $slug2;
        $slug1Routes = ['sportdoelen', 'groepslessen', 'vrij-sporten', 'voedingsadvies', 'personal-training'];
        $slug2Routes = ['body-attack', 'body-balance', 'buikspierkwartier', 'club-power', 'disq', 'fiesta-zumba', 'fit-shape', 'fit-vitaal', 'fysiofitness', 'streetdance-kids-teens', 'club-cycle-freestyle-spinning'];



        if(isset($slug2)&&isset($slug1))
        {
            if(!in_array($slug2, $slug2Routes)){
                \App::abort(404);
            }
            $this->data = array_merge($this->data, $this->sportsService->getContent($slug1));
            $this->data = array_merge($this->data, $this->sportsService->getOneGroupLesson($slug2));
            return \View::make('layouts.pages.subSelection')->with('data', (object)$this->data);
        }

        if(isset($slug1))
        {

            if(!in_array($slug1, $slug1Routes)){
                \App::abort(404);
            }

            $this->data = array_merge($this->data, $this->sportsService->getContent($slug1));

            if($slug1=='groepslessen')
            {
                return \View::make('layouts.pages.overview')->with(['data'=> (object) $this->data, 'groupLessonsOverview'=>$this->sportsService->getGroupLessonsOverview()]);
            }
            elseif($slug1=='tarieven')
            {
                return \Redirect::action('SportsController@prices');
            }
            elseif($slug1=='sportdoelen')
            {
                $this->data['multiData'] = $this->sportsService->getSportPurposes();
                return \View::make('layouts.pages.modelView')->with(['data'=> (object) $this->data]);
            }
            else
            {
                return \View::make('layouts.pages.defaultPage')->with('data', (object)$this->data);
            }
        }

        return \View::make('layouts.pages.defaultPage')->with('data', (object)$this->data);
    }

    public function prices(){
        $this->data = array_merge($this->data, $this->sportsService->getContent('general'));
        $this->data = array_merge($this->data, $this->sportsService->getContent('tarieven'));
        $inlineButton =  ['color'=>'orange',
                          'url' => $this->pageService->getDocument('Tarieven'),
                          'value'=>'Download de algemene tarieven',
                          'target' => '_blank',
                          'download'=>true ];
        $this->data = array_merge($this->data, ['inlineButton'=>$inlineButton]);
        $this->data['multiData'] = $this->sportsService->getPrices();
        $this->data['prices'] = true;
        return \View::make('layouts.pages.prices')->with(['data'=> (object) $this->data]);
    }

    public function lesrooster(){
        $this->data = array_merge($this->data, $this->sportsService->getContent('general'));
        $this->data = array_merge($this->data, $this->sportsService->getContent('lesrooster'));
        $inlineButton =  ['color'=>'orange',
                                           'url' => $this->pageService->getDocument('Lesrooster'),
                                           'value'=>'Download het lesrooster',
                                           'target' => '_blank',
                                           'download'=>true ];
        $this->data = array_merge($this->data, ['inlineButton'=>$inlineButton]);
        return \View::make('layouts.pages.defaultPage')->with('data', (object)$this->data);
    }
}