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/rentman.komma.pro/app/Komma/Routes/RouteResolver.php
<?php

namespace Komma\Routes;

class RouteResolver
{
    /**
     * Resolve route
     *
     * @return bool
     */
    public function resolve()
    {

        \Route::get('getMoreUpdates/{start}', 'Komma\Updates\UpdateController@getMoreUpdates');
        // Return false when we are in the control panel
        if($this->isControlPanel()) return false;
        // Maybe we are receiving an alias
        // Check for a REST-route that belongs to this alias and dispatch a new Request
        \Route::get(\Request::path(), function ()
        {
            // Return a 404 when the alias is not found in the database
            if( ! $dispatch = $this->dispatchRoute()) \App::abort(404);

            return $dispatch;
        });

        \Route::post(\Request::path(), function ()
        {
            // Return a 404 when the alias is not found in the database
            if( ! $dispatch = $this->dispatchPostRoute()) \App::abort(404);

            return $dispatch;
        });

        //Project Routes
        \Route::get('updates', 'Komma\Updates\UpdateController@index');
        \Route::get('updates/{updateId}', 'Komma\Updates\UpdateController@show');



        //Project Routes
        \Route::get('projects', 'Komma\Projects\ProjectController@index');
        \Route::get('projects/{projectId}', 'Komma\Projects\ProjectController@show');

        //Jobs Routes
        \Route::get('jobs', 'Komma\Jobs\JobController@index');
        \Route::get('jobs/{jobId}', 'Komma\Jobs\JobController@show');

        //Post Routes
        \Route::get('blog', 'Komma\Posts\PostController@index');
        \Route::get('blog/{blogId}', 'Komma\Posts\PostController@show');

        //News Routes
        \Route::get('news', 'Komma\Posts\PostController@index');
        \Route::get('news/{newsId}', 'Komma\Posts\PostController@show');

        // Page Routes
        \Route::resource('pages', 'Komma\Pages\PageController');

        // Forms
        \Route::post('contact/process', [
            'as'   => 'contact.process',
            'uses' => 'Komma\Contact\ContactController@contactFormProcess'
        ]);

        \Route::get('contact', ['as'   => 'contact.form',
                                'uses' => 'Komma\Contact\ContactController@contactForm'
        ]);
        \Route::get('contact/success', ['as'   => 'contact.success',
                                        'uses' => 'Komma\Contact\ContactController@contactSuccess'
        ]);

        \Route::post('storeToSession', ['uses' => 'Komma\Contact\ContactController@storeToSession']);

        \Route::any('trial', [
            'as'   => 'trial.page',
            'uses' => 'Komma\Contact\ContactController@freeTrialForm']);

        \Route::post('trial/process', [
            'as'   => 'trial.process',
            'uses' => 'Komma\Contact\ContactController@freeTrialProcess'
        ]);

        \Route::get('trial/in-use', [
            'as'   => 'trial.in-use',
            'uses' => 'Komma\Contact\ContactController@freeTrialSuccess'
        ]);

        \Route::get('trial/succes', [
            'as'   => 'trial.success',
            'uses' => 'Komma\Contact\ContactController@freeTrialSuccess'
        ]);

        \Route::get('trial/error', [
            'as'   => 'trial.error',
            'uses' => 'Komma\Contact\ContactController@freeTrialSuccess'
        ]);

        \Route::get('trial/ip-already-exist', [
            'as'   => 'trial.ipExist',
            'uses' => 'Komma\Contact\ContactController@freeTrialSuccess'
        ]);

        \Route::post('setLanguage', 'BaseController@setCurrentLanguage');
        \Route::post('setCurrency', 'BaseController@setCurrency');

        // SEO routes
        \Route::get('robots.txt', 'Komma\Sitemap\SitemapController@robots');
        \Route::get('sitemap.xml', 'Komma\Sitemap\SitemapController@sitemap');

        //404 route for maps in wwwroot
        \Route::get('404', 'BaseController@abortPage');

        \Route::get('nl/gratis-uitproberen', function (){
            return \Redirect::to('/nl/probeer-gratis', 301);
        });

    }

    /**
     * Dispatch new custom event with REST-route
     *
     * @return mixed
     */
    private function dispatchRoute()
    {
        $requestUri = \Request::path();

        //custom 301 for all toepassingen-links
        if(str_contains($requestUri, 'nl/toepassingen')) return \Redirect::to(str_replace(['nl/toepassingen'], ['nl/functies'], $requestUri), 301);

        // Get route by URI
        if( ! $route = \DB::table('routes')
            ->where('route', '=', $requestUri)
            ->first()
        ) return false;
        // Create get request

        $request = \Request::create('/' . $route->rest_route, 'GET');

        // Dispatch request
        return \Route::dispatch($request);
    }

    private function dispatchPostRoute()
    {
        $requestUri = \Request::path();
        // Get route by URI
        if( ! $route = \DB::table('routes')
            ->where('route', '=', $requestUri)
            ->first()
        ) return false;

        if( ! in_array($route->rest_route, ['contact', 'trial'])) return false;
        // Create get request
        $request = \Request::create('/' . $route->rest_route, 'POST');

        // Dispatch request
        return \Route::dispatch($request);
    }

    /**
     * Check if the routes starts with "KMS"
     *
     * @return mixed
     */
    private function isControlPanel()
    {
        return \Str::startsWith(\Request::path(), 'kms');
    }
}