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/Neopoints/momsecurity.be/app/Testimonials/TestimonialController.php
<?php

namespace App\Testimonials;

use App\Base\Controller;
use App\Buttons\Models\Button;
use App\PostLabels\Models\PostLabel;
use App\Posts\Models\Post;
use App\Testimonials\Models\Testimonial;
use Komma\KMS\Components\ComponentService;

final class TestimonialController extends Controller
{
    private $testimonialService;
    private $testimonialPaginationKey = 'testimonialPagination';

    public function __construct(TestimonialService $testimonialService)
    {
        parent::__construct();
        $this->testimonialService = $testimonialService;
    }

    /**
     * @return \Illuminate\Contracts\View\View
     */
    public function index()
    {
        $page = $this->links->references->node;

        $testimonials = $this->testimonialService->getAllTestimonials();
//        $testimonials->withPath($this->links->posts->route);

        // Make language menu for given page
        $languageMenu = $this->pageService->makeLanguageSwitchForPage($this->links->{$page->code_name}, $this->links->home);
        $this->keepTrackOfPagination($this->testimonialPaginationKey);

        // Return view
        return view('templates.testimonials_index',[
            'page' => $page,
            'links' => $this->links,
            'languageMenu' => $languageMenu,
            'testimonials' => $testimonials,
        ]);
    }

    /**
     * @param Testimonial $testimonial
     * @return \Illuminate\Contracts\View\View
     */
    public function show(Testimonial $reference)
    {
        $testimonial = $reference;
        $testimonial->load('translation', 'translations');

        $page = $this->links->references->node;

        // Make language menu for given page
        $languageMenu = $this->pageService->makeLanguageSwitchForPage($this->links->{$page->code_name}, $this->links->home);

        $componentService = app(ComponentService::class);
        $components = $componentService->getViewComponents($testimonial->translation);

//         Create previous route for better navigation UX
//        $previousRoute = $this->createPreviousRoute($this->postPaginationKey, $this->links->posts->route);

        $nextTestimonials = $this->testimonialService->getNextTestimonials($testimonial);

        // Return view
        return view('templates.testimonials_show',[
            'page' => $page,
            'testimonial' => $testimonial,
            'nextTestimonials' => $nextTestimonials,
            'components' => $components,
            'links' => $this->links,
            'languageMenu' => $languageMenu,
        ]);
    }
}