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/meuwis/lmbm.be/app/KommaApp/Services/ServiceController.php
<?php

namespace App\KommaApp\Services;

use App\Http\Controllers\Controller;
use App\KommaApp\Services\Models\Service;

class ServiceController extends Controller
{
    private $pagePrefix = 'pages.services.';
    private $serviceService;

    public function __construct(ServiceService $serviceService)
    {
        parent::__construct();
        $this->serviceService = $serviceService;
    }

    /**
     * @return \Illuminate\Contracts\View\View
     */
    public function index()
    {
        $page = $this->pageService->getPageByCodeName('services');
        $otherLanguageRoutes = $this->languageService->getOtherLanguagesRoutes($page);

        $services = $this->serviceService->getAllServices(true);
        $services->withPath('/' . $this->links->services->route);

        // Decode the dynamic content
        $page->translation = $this->decodeDynamicContent( $page->translation );

        // Return view
        return \View::make($this->baseViewPath.$this->pagePrefix.'index',[
            'page' => $page,
            'links' => $this->links,
            'otherLanguages' => $otherLanguageRoutes,
            'services' => $services,
        ]);
    }

    /**
     * @return \Illuminate\Contracts\View\View
     */
    public function filters()
    {
        $filters = request('filters');
        dd('customize filter function in ServiceController');

//        if (sizeof($filters) != 1) {
//            throw abort(404);
//        }
//        $categoryName = $filters[0];
//
//        // Check if category exist else trow 404
//        if ( ! $category = ServiceCategoryTranslation::where('slug', $categoryName)
//            ->with('translatable')
//            ->first()) {
//            throw abort(404);
//        }
//
//        $page = $this->pageService->getPageByCodeName('blog');
//        $otherLanguageRoutes = $this->languageService->getOtherLanguagesRoutes($page);
//
//        //Get services through the category
//        $services = $category->translatable->services()->paginate(8);
//        $services->withPath('/' . $this->links->blog->route . '/' . $category->slug);
//
//
//        // Return view
//        return \View::make($this->baseViewPath.$this->pagePrefix.'index',[
//            'page' => $page,
//            'links' => $this->links,
//            'otherLanguages' => $otherLanguageRoutes,
//            'services' => $services,
//        ]);
    }

    /**
     * @param Service $service
     * @return \Illuminate\Contracts\View\View
     */
    public function show(Service $service)
    {
        $service->load('translation');

        $page = $this->pageService->getPageByCodeName('services');
        $otherLanguageRoutes = $this->languageService->getOtherLanguagesRoutes($page, $service);

        // Load all Services
        $services = $this->serviceService->getAllServices();

        // Decode the dynamic content
        $service->translation = $this->decodeDynamicContent( $service->translation );

        // Return view
        return \View::make($this->baseViewPath.$this->pagePrefix.'show',[
            'page' => $page,
            'service' => $service,
            'links' => $this->links,
            'services' => $services,
            'otherLanguages' => $otherLanguageRoutes,
        ]);
    }

}