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/immoginis.komma.pro/app/Komma/Properties/PropertyController.php
<?php

namespace Komma\Properties;

use Illuminate\Support\Facades\Redirect;
use Komma\BaseController;
use Komma\Kms\Pages\Models\Page;
use Komma\Pages\PageService;


class PropertyController extends \BaseController
{

    private $propertyService;

    public function __construct(PageService $pageService, PropertyService $propertyService){
        parent::__construct();
        $this->pageService = $pageService;
        $this->propertyService = $propertyService;

        $this->data = (object)[];
    }

    public function show($id = 1)
    {
        $property = $this->propertyService->decodeProperties($this->propertyService->getProperty($id))[0];
        $this->data->id = 3 ;

        //generate the Return button with filters
        $filterString = '/aanbod?';
        if(\Session::has('result'))
        {
            foreach (\Session::get('result') as $key => $filter)
            {
                if($key != 'filters')
                {
                    if($key != 'city')
                    {
                        $filterString .= '&';
                    }
                    $filterString .= $key . '=' . $filter;
                }
                else
                {
                    foreach ($filter as $type)
                    {
                        $filterString .= '&' . $type . '=1';
                    }
                }
            }
        }

        $this->data->filterString = $filterString;

        if($property->type == 'Project'){

            $subProperties = $this->propertyService->decodeProperties($this->propertyService->getProjectProperties($property->omnicasa_id));

            return \View::make('layouts.pages.project')->with([
                'data' => $this->data,
                'property' => $property,
                'subProperties' => $subProperties
            ]);
        }

        if(isset($property->project_id)){
            $project = $this->propertyService->getProjectPropertyByOmnicasaId($property->project_id);
            $property->projectRoute = $project->routes->first()->route;
            $property->project = $project;
        }

        if($property->goal == 'reference'){
            $this->data->id = 8 ;
            return \View::make('layouts.pages.propertyReference')->with([
                'data' => $this->data,
                'property' => $property,
            ]);
        }

        return \View::make('layouts.pages.property')->with([
            'data' => $this->data,
            'property' => $property,
        ]);
    }

    public function showProperties( $city = null)
    {

        $page = Page::where('code_name', '=','offer')->first();

        $this->data->id = $page->id ;
        $this->data->content = $this->pageService->getPageContent($page->id);
        $this->data->city = $city;

        $formInfo = $this->propertyService->getForminfo();

        return \View::make('layouts.pages.'.$this->data->content->code_name)
            ->with([
                'data' => $this->data,
                'formInfo' => $formInfo,
                'cities' => $this->propertyService->getCities(),
                'citySets' => $this->propertyService->getCitySets(),
            ]);
    }

    public function updateFilterSession(){
        $this->propertyService->updateFilterQuery();
    }

    public function omnicasaLink($omnicasaId) {

        $property = $this->propertyService->getPropertyByOmnicasaId($omnicasaId);
        if(!isset($property) || $property->routes->count() == 0) return $this->abortPage();

        return Redirect::to($property->routes->first()->route);

    }

}