<?php

//use Illuminate\Support\Facades\Route;

/*
  |--------------------------------------------------------------------------
  | Web Routes
  |--------------------------------------------------------------------------
  |
  | Here is where you can register web routes for your application. These
  | routes are loaded by the RouteServiceProvider within a group which
  | contains the "web" middleware group. Now create something great!
  |
 */

//Route::get('language/{id}/{slug?}', 'LanguageController@details');
/**
 * Localization Group
 */
Route::group(['prefix' => LaravelLocalization::setLocale()], function () {

    Route::group(['namespace' => 'Web', 'middleware' => ['checkWebSiteEnabled', 'WebsiteVisitorCount','ServiceValid']], function () {
        //Home
        Route::get('/', 'HomeController@index')->name('home');

        Route::get('/test', 'CronController@cobonBithDay');
        //Page
        Route::get('/aboutus', 'PageController@aboutus')->name('aboutus');
        Route::get('/contactus', 'PageController@contactus')->name('contactus');
        Route::post('/contactus', 'PageController@contact')->name('contacting');
        Route::post('/newsletter', 'PageController@newsletter')->name('newsletter');
        Route::post('/send-email', 'PageController@sendEmail')->name('sendEmail');
        Route::get('/conditions/user', 'PageController@conditions')->name('conditions');
        Route::get('/conditions/company', 'PageController@conditionsCompany')->name('conditions.company');
        Route::get('/privacy', 'PageController@privacy')->name('privacy');

        Route::get('fetch/cities', 'FetchController@cities')->name('fetch.cities');
        Route::get('fetch/attribute/sub', 'FetchController@attributeSub')->name('fetch.attributeSub');
        Route::get('fetch/attribute/sub/product', 'FetchController@attributeSubProduct')->name('fetch.subAttrProduct');
        Route::get('fetch/showCount', 'FetchController@showCount')->name('fetch.showCount');


        Route::post('favorite','FavoriteController@store')->name('product.favorite');
        Route::get('favorite','FavoriteController@index')->name('product.favorites');

        Route::post('cart/{id}','CartController@store')->name('product.cart');
        Route::get('cart','CartController@index')->name('product.carts');
        Route::post('cart/edit/{id}','CartController@edit')->name('product.cart.edit');
        Route::get('cart/delete/{id}','CartController@delete')->name('product.cart.delete');


        Route::get('currency/{id}','CurrencyController@setCurrency')->name('currency.set');
        Route::get('product/{id}','ProductController@product')->name('product');
        Route::get('search','ProductController@search')->name('search');
        Route::get('filter/{id}','ProductController@filter')->name('filter');
        Route::get('filter','ProductController@products')->name('products');
        Route::post('filter/{id}','ProductController@filtering')->name('filtering');


        Route::group(['prefix' => 'rate' ], function ()
        {
            Route::post('/{id}','RateController@rating')->name('rating.product');
        });
        Route::group(['prefix' => 'checkout' ], function ()
        {
            Route::get('order/calculate','OrderController@calculate')->name('order.calculate');
            Route::post('order','OrderController@order')->name('order');
            Route::get('order/{token}','OrderController@orderDetails')->name('order.details');

            Route::get('/location','OrderController@checkoutLocation')->name('checkout.location');
            Route::post('/location','OrderController@checkoutingLocation')->name('checkouting.location');

            Route::get('/method','OrderController@checkoutMethod')->name('checkout.method');
            Route::post('/method','OrderController@checkoutingMethod')->name('checkouting.method');

            Route::get('/payment','OrderController@checkoutPayment')->name('checkout.payment');
            Route::post('/payment','OrderController@checkoutingPayment')->name('checkouting.payment');
        });

        Route::group(['middleware' => [ 'GuestAuth'] ], function ()
        {
            //Auth Request
            Route::get('login','AuthController@login')->name('login');
            Route::post('login','AuthController@check')->name('login_check');

            Route::get('forgetpassword','AuthController@forgetpassword')->name('forgetpassword');
            Route::post('forgetpassword','AuthController@forgettingpassword')->name('forgettingpassword');

            Route::get('verify/code','AuthController@verify')->name('verify');
            Route::post('verify/code','AuthController@verifying')->name('verifying');

            Route::get('resetpassword','AuthController@resetpassword')->name('resetpassword');
            Route::post('resetpassword','AuthController@resetting')->name('resetting');

            Route::get('regist','AuthController@regist')->name('regist');
            Route::post('regist','AuthController@registing')->name('registing');
            Route::get('regist/company','AuthController@registCompany')->name('regist.company');
            Route::post('regist/company','AuthController@registingCompany')->name('registing.company');
        });

        Route::group(['middleware' => [ 'AuthLogin'] ], function ()
        {
            Route::group(['prefix' => 'profile' ], function ()
            {
                Route::get('/','ProfileController@profile')->name('profile');
                Route::group(['prefix' => 'locations' ], function ()
                {
                    Route::get('/','LocationController@index')->name('profile.locations');
                    Route::get('delete/{id}','LocationController@delete')->name('profile.location.delete');
                    Route::post('store','LocationController@store')->name('profile.location.store');
                    Route::get('create','LocationController@create')->name('profile.location.create');
                    Route::post('update/{id}','LocationController@update')->name('profile.location.update');
                    Route::get('edit/{id}','LocationController@edit')->name('profile.location.edit');
                });
                Route::get('notifications','ProfileController@notifications')->name('profile.notifications');
                Route::get('orders','ProfileController@orders')->name('profile.orders');
            });


            Route::get('orders','ProfileController@orders')->name('orders');
            Route::get('order/status','ProfileController@showOrder');
            Route::get('locations','ProfileController@locations')->name('locations');
            Route::get('notifications','ProfileController@notifications')->name('notifications');

            Route::post('profile','ProfileController@editProfile')->name('edit_profile.user');
            Route::post('profile/company','ProfileController@editProfileCompany')->name('edit_profile.company');
            Route::post('profile/verification','ProfileController@verification')->name('verification.company');
            Route::get('logout','AuthController@logout')->name('logout');



        });

    });

});
