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/SBogers101/cranendonckactief.nl/app/Komma/Routes/RouteResolver.php
<?php

namespace Komma\Routes;


class RouteResolver
{
    /**
     * Resolve route
     *
     * @return bool
     */
    public function resolve()
    {
        // Return false when we are in the control panel
        if($this->isControlPanel()) return false;


        \Route::get('/_debugbar/assets/stylesheets', [
            'as'   => 'debugbar-css',
            'uses' => '\Barryvdh\Debugbar\Controllers\AssetController@css'
        ]);

        \Route::get('/_debugbar/assets/javascript', [
            'as'   => 'debugbar-js',
            'uses' => '\Barryvdh\Debugbar\Controllers\AssetController@js'
        ]);


        // 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;
//        });

        //\Route::get('test-searchpage', 'Komma\Search\SearchController@searchPages');

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

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

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


        // Forms


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

        \Route::post('subscribe/process', [
            'before'   => 'csrf',
            'as'   => 'subscribe.process',
            'uses' => 'Komma\Contact\ContactController@subscribeFormProcess'
        ]);
        \Route::get('subscribe/succes', ['as'   => 'subscribe.success',
                                       'uses' => 'Komma\Contact\ContactController@subscribeSuccess'
        ]);

//        \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::post('setLanguage', 'BaseController@setCurrentLanguage');


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

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

    }

    /**
     * Dispatch new custom event with REST-route
     *
     * @return mixed
     */
    private function dispatchRoute()
    {
        $requestUri = \Request::path();
        // Get route by URI
        if( ! $route = \DB::table('routes')
            ->where('route', '=', $requestUri)
            ->first()
        ) return $this->redirectOldPages($requestUri);
        // 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']) || starts_with($route->rest_route, 'photo_albums'))) 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');
    }

    /**
     * Dispatch Old routes
     *
     * @return mixed
     */
    private function redirectOldPages($requestUri = null)
    {

        // Assign old routes
        switch ($requestUri){
            case 'index.html':
                return \Redirect::to('/', 301);
                break;

            case 'nieuws.html':
            case 'agenda.html':
                return \Redirect::to('/nieuws', 301);
                break;

            case 'jaarverslagen.html':
            case 'beginselverklaring.html':
            case 'bestuur.html':
            case 'beloningsbeleid.html':
            case 'over-cra!.html':
                return \Redirect::to('/over-ons', 301);
                break;

            case 'liddonateur-worden.html':
                return \Redirect::to('/lid-worden', 301);
                break;

            case 'contact.html':
            case 'uw-mening.html':
                return \Redirect::to('/contact', 301);
                break;

            case 'judith-blaauw.html':
            case 'erica-de-graaf.html':
            case 'david-morgan.html':
            case 'koen-van-laarhoven.html':
            case 'andre-oud.html':
            case 'karel-boonen.html':
            case 'josé-corporaal.html':
            case 'downloads.html':
                return \Redirect::to('/kieslijst', 301);
                break;

            case 'in-de-raad.html':
            case 'aantrekkelijk.html':
            case 'aantrekkelijk-d.html':
            case 'aantrekkelijk-j.html':
            case 'jan-van-tulden.html':
            case 'aantrekkelijk-f.html':
            case 'aantrekkelijk-c.html':
            case 'aantrekkelijk-i.html':
            case 'aantrekkelijk-g.html':
            case 'aantrekkelijk-l.html':
            case 'kernpunten-2014-2018.html':
            case 'saamhorig.html':
            case 'saamhorig-c.html':
            case 'saamhorig-i.html':
            case 'saamhorig-f.html':
            case 'aantrekkelijk-a.html':
            case 'betaalbaar-d.html':
            case 'wethouder.html':
            case 'betaalbaar.html':
            case 'betaalbaar-a.html':
            case 'betaalbaar-g.html':
            case 'betaalbaar-c.html':
            case 'betaalbaar-f.html':
            case 'betaalbaar-l.html':
            case 'betaalbaar-i.html':
            case 'betaalbaar-j.html':
            case 'dienstbaar.html':
            case 'dienstbaar-a.html':
            case 'dienstbaar-g.html':
            case 'dienstbaar-c.html':
            case 'dienstbaar-i.html':
            case 'saamhorig-a.html':
            case 'betaalbaar-k.html':
            case 'dienstbaar-j.html':
            case 'aantrekkelijk-k.html':
            case 'aantrekkelijk-h.html':
            case 'aantrekkelijk-e.html':
            case 'betaalbaar-e.html':
            case 'betaalbaar-h.html':
            case 'saamhorig-g.html':
            case 'aantrekkelijk-b.html':
            case 'betaalbaar-b.html':
            case 'saamhorig-e.html':
            case 'betaalbaar-m.html':
            case 'dienstbaar-h.html':
            case 'dienstbaar-e.html':
            case 'dienstbaar-b.html':
                return \Redirect::to('/verkiezingsprogramma', 301);
                break;

            default:
                break;

        }

        return false;

    }
}