File: D:/HostingSpaces/SBogers10/debierbaron.komma.pro/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;
// Forms
\Route::post('form/offer/process',[
'as' => 'form.offer.process',
'uses' => 'Komma\Forms\FormController@process'
]);
//Shop Routes pt 1
\Route::get('add-to-cart/{product}/{quantity?}',['uses'=> 'Komma\Shop\ShopController@addProductToCart', 'as'=> 'shop.addToCart']);
\Route::post('api/cart/update-product/{product}',['uses'=> 'Komma\Shop\ShopController@ajaxUpdateProductToCart', 'as'=> 'shop.updateProduct']);
\Route::post('api/cart/delete-product/{product}',['uses'=> 'Komma\Shop\ShopController@ajaxDeleteProductFromCart', 'as'=> 'shop.deleteProduct']);
\Route::post('api/cart/validate-coupon',['uses'=> 'Komma\Shop\ShopController@ajaxValidateCoupon', 'as'=> 'shop.validateCoupon']);
\Route::post('api/payment-response/{orderId?}',['uses'=> 'Komma\Payments\PaymentController@updatePayment', 'as'=> 'payment.update']);
\Route::post('api/subscription-payment-response',['uses'=> 'Komma\Payments\PaymentController@updateSubscriptionPayment', 'as'=> 'subscription-payment.update']);
\Route::get('api/subscription-payment-response',['uses'=> 'Komma\Payments\PaymentController@updateSubscriptionPayment', 'as'=> 'subscription-payment.update']);
// \Route::get('subscription/pay-monthly',['uses'=> 'Komma\Payments\PaymentController@newSubscriptionPayment', 'as'=> 'subscription.payment.new']);
if($route = $this->getRoute()){
// 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() use ($route)
{
// Return a 404 when the alias is not found in the database
if( ! $dispatch = $this->dispatchRoute($route)) \App::abort(404);
return $dispatch;
});
}
\Route::get('api/payment-response/{orderId?}',['uses'=> 'Komma\Payments\PaymentController@updatePayment', 'as'=> 'payment.update']);
//Shop routes
\Route::get('checkout',['uses'=> 'Komma\Shop\ShopController@checkout', 'as'=> 'shop.checkout']);
\Route::post('checkout',['uses'=> 'Komma\Shop\ShopController@processCheckout', 'as'=> 'shop.checkout']);
\Route::get('checkout-subscription',['uses'=> 'Komma\Shop\ShopController@checkoutSubscription', 'as'=> 'shop.checkout-subscription']);
\Route::post('checkout-subscription',['uses'=> 'Komma\Shop\ShopController@processCheckoutSubscription', 'as'=> 'shop.checkout-subscription']);
// Page Routes
\Route::resource('pages','Komma\Pages\PageController' );
// Newsletter Route
\Route::post('gerstenat-gazet',['uses'=>'Komma\Newsletters\NewsLetterController@subscribe', 'as' => 'newsLetter.gerstenat-gazet']);
// Blog Routes
\Route::get('blog','Komma\Blog\BlogController@index' );
\Route::get('blog/{blog}','Komma\Blog\BlogController@detail' );
// Box Routes
\Route::get('boxen','Komma\Boxes\BoxController@index' );
\Route::get('boxen/{box}','Komma\Boxes\BoxController@detail' );
// SEO routes
\Route::get('robots.txt', 'Komma\Seo\SEOController@robots');
\Route::get('sitemap.xml','Komma\Seo\SEOController@sitemap');
}
/**
* Dispatch new custom event with REST-route
*
* @return mixed
*/
private function dispatchRoute($route)
{
// Create get request
$request = \Request::create('/'.$route->rest_route, 'GET');
// Dispatch request
return \Route::dispatch($request);
}
public function getRoute(){
// URI
$requestUri = \Request::path();
// Get route by URI
if( ! $route = \DB::table('routes')
->where('route','=', $requestUri)
->first()) return false;
return $route;
}
/**
* Check if the routes starts with "KMS"
*
* @return mixed
*/
private function isControlPanel()
{
return \Str::startsWith(\Request::path(),'kms');
}
}