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/SportsService.php
<?php


namespace Komma\Sports;
use Carbon\Carbon;


class SportsService {

    protected $sportRepository;

    public function __construct(SportsRepository $sportsRepository){
        $this->sportRepository = $sportsRepository;
    }

    public function getGroupLessons(){
        return $this->sportRepository->allGroupLesson();
    }

    /**
     * Load all information for a group lesson page
     *
     * @param $slug
     * @return array
     */
    public function getOneGroupLesson($slug){
        $article = $this->sportRepository->get($slug);
        return [
            'content' => ['header' => $article->name,
                                        'tm'     => $article->tm,
                                        'text'   => $article->intro,
                                        'text2'  => $article->description,
                                        'image'  => (isset($article->large_image_url)) ? $article->large_image_url : 'http://placehold.it/725x400'
                         ],
            'subscribeButton' =>['url'   => '/contact/aanmelden-proefles?to=' . $slug,
                                 'value' => 'Aanmelden voor ' . $article->name,
                                 'color' => 'blue'],
            'articleBlock'=>['header'   => 'Bekijk eens deze sporten',
                             'articles' => $this->getRandomGroupLessons(2, $slug),
                             'footer'   => 'Bekijk sporten overzicht',
                             'url'      => '/sporten']
        ];
    }

    public function getGroupLessonsOverview(){
        return $this->sportRepository->getOverview();
    }

    public function getRandomGroupLessons($amount, $id){
        return $this->sportRepository->getRandom($amount, $id);
    }

    /**
     * Get the prices and pair the button from the Buttons.php
     *
     * @return array
     */
    public function getPrices(){
        $array = $this->sportRepository->getPrices();
        $newArray = [];

        foreach($array as $price){
            if(isset($price->direct_button)&&($price->direct_button!='0')){
                $newArray[] = (object)['name' => $price->name,'slug' => $price->slug, 'description' => $price->description, 'stars' => $price->stars, 'subscribeButton'=>$this->sportRepository->getButton($price->direct_button)];
            }
            else
            {
                $newArray[] = (object)['name' => $price->name,'slug' => $price->slug, 'description' => $price->description, 'stars' => $price->stars];
            }
        }

        return $newArray;
    }

    /**
     * Get the Sport purposes, pair the button from the Buttons.php and prepare for Front-end
     *
     * @return array
     */
    public function getSportPurposes(){
        $array =  $this->sportRepository->getSportPurposes();
        $newArray = [];

        foreach($array as $purpose){
                $newArray[] = (object)['name' => $purpose->name,'large_image_url' => $purpose->large_image_url, 'description' => $purpose->description, 'intro' => $purpose->intro, 'subscribeButton'=>$this->sportRepository->getButton($purpose->direct_button)];
        }

        return $newArray;
    }

    public function getSportPurposesCircles(){

        return $this->sportRepository->getSportPurposesCircles();
    }

    public function getContent($key)
    {
        return $this->sportRepository->getContent($key);
    }

}