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/centrum8a/centrum8a.com/app/KommaApp/Dates/DateController.php
<?php

namespace App\KommaApp\Dates;

use App\Http\Controllers\Controller;
use App\KommaApp\Dates\Models\Date;

class DateController extends Controller
{
    private $pagePrefix = 'pages.dates.';
    private $dateService;

    public function __construct(DateService $dateService)
    {
        parent::__construct();
        $this->dateService = $dateService;
    }

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

        $dates = $this->dateService->getAllDates(true);
        $dates->withPath('/' . $this->links->dates->route);

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

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

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

    /**
     * @param Date $date
     * @return \Illuminate\Contracts\View\View
     */
    public function show(Date $date)
    {
        $date->load('translation','translations', 'site');

        // This checks if the date belongs to the set site
//        if($date->site != \App::getSite()) throw abort(404);

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

        // Get the latest dates
        $dates = $this->dateService->getLatestDates();

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

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

}