<?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!
|
*/

use App\Order;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;

//Route::get('language/{id}/{slug?}', 'LanguageController@details');
/**
 * Localization Group
 */

Route::group(['prefix' => LaravelLocalization::setLocale()], function(){

     Route::get('/test', function () {
        $response = \App\Http\Controllers\Web\AramexController::createShipments();
         // return redirect('/admin/login');
     });

    Route::group(['namespace' => 'Web','middleware' => [ 'checkWebSiteEnabled', 'WebsiteVisitorCount'] ], function () {
        Route::get('/', 'HomeController@index')->name('home');
        Route::get('/get-product-details', 'HomeController@getProductDetails')->name('getProductDetails');
        Route::get('/policy', 'HomeController@policy')->name('policy');
        Route::get('about-us', 'AboutUsController@index')->name('aboutUs');
        Route::get('services', 'ServiceController@index')->name('ourServices');

        // newsletter and contact us routes
        Route::get('/contact-us', 'VisitorMessageController@index')->name('contactUs');
        Route::post('/contact-us', 'VisitorMessageController@store')->name('send_contact_us');
        Route::post('/newsletter', 'NewsletterController@store')->name('newsletter');


//        Route::get('/login/', 'UserController@login')->name('user.login');
//        Route::post('/login', 'UserController@doLogin')->name('user.doLogin');
//        Route::get('/register', 'UserController@register')->name('user.register');
//        Route::post('/register', 'UserController@doRegister')->name('user.doRegister');
//        Route::get('/getState', 'UserController@getState')->name('user.getState');
//
//        Route::get('/forget-password', 'UserController@forgetPasswordForm')->name('user.forgetPassword');
//        Route::post('/send-forget-password-code', 'UserController@sendForgetPasswordCode')->name('user.sendForgetPasswordCode');
//        Route::get('/type-forget-password-code', 'UserController@typeForgetPasswordCode')->name('user.typeForgetPasswordCode');
//        Route::post('/code-verification', 'UserController@codeVerification')->name('user.codeVerification');
//        Route::get('/new-password', 'UserController@newPasswordForm')->name('user.newPasswordForm');
//        Route::post('/resetPassword', 'UserController@resetPassword')->name('user.resetPassword');


        Route::group(['middleware' => 'RedirectToPreviousLink'], function () {
            Route::group(['middleware' => 'UserAuth'], function (){

                Route::any('/logout', 'UserController@logout')->name('user.logout');
                Route::get('/user/profile', 'UserController@index')->name('user.profile');
                Route::post('/updateProfile/{user}', 'UserController@updateProfile')->name('user.updateProfile');
                Route::get('/user/markAsRead', 'UserController@markAsRead')->name('user.markAsRead');
                Route::get('user/refreshNotification', 'UserController@refreshNotification')->name('user.refreshNotification');

                Route::get('/cart', 'ProductController@cart')->name('product.cart');
                Route::post('product/evaluate', 'ProductController@evaluate')->name('product.evaluate');
                Route::post('product/checkCoupon', 'ProductController@checkCoupon')->name('product.checkCoupon');
                Route::post('product/changeAmount', 'ProductController@changeAmount')->name('product.changeAmount');
                Route::post('product/delete', 'ProductController@delete')->name('product.delete');
                Route::post('product/payNow', 'ProductController@payNow')->name('product.payNow');
                Route::get('check-address', 'ProductController@checkAddress')->name('product.checkAddress');
                Route::post('check-address', 'ProductController@checkAddressAndRedirectToCompletePay')->name('product.checkAddressAndCompletePay');
                Route::get('complete-pay', 'ProductController@completePay')->name('product.completePay');
                Route::post('product/evaluate', 'ProductController@productEvaluate')->name('product.evaluate');

                Route::post('product/payment', 'MyFatoorah@productPay')->name('product.finishPay');
                Route::get('callback', 'MyFatoorah@callback')->name('callback');

            });
        });

    });


    /**
     * this route for the central admin and central super admin to enable them to use this website
     */
    Route::get('/login/{admin_token}', 'Auth\LoginController@superAdminLogin')->name('superAdminLogin');

    /**
     * Authentication routes , and Authentication user routs
     */
//	Auth::routes();

    /**
     * Admin Routes
     */
    Route::group([ 'prefix'=> 'admin', 'namespace' => 'Admin'], function () {

        Route::get('/login', 'LoginController@index');
        Route::post('/login', 'LoginController@authenticate')->name('admin_login');

        Route::group([ 'middleware' => ['admin_auth']], function () {
            Route::get('/', 'DashboardController@index')->name('dashboard');

            Route::post('/logout', 'LoginController@logout')->name('admin_logout');

            Route::group([ 'middleware' => ['checkRole']], function () {

                Route::get('/abouts/grid', 'AboutController@grid')->name('abouts.grid');
                Route::resource('/abouts', 'AboutController')->only(['index','edit', 'update']);

                Route::put('/features/restore/{id}', 'FeatureController@restore')->name('features.restore');
                Route::put('/features/restore', 'FeatureController@restoreAll')->name('features.restoreAll');
                Route::delete('/features', 'FeatureController@destroyAll')->name('features.destroyAll');
                Route::get('/features/grid', 'FeatureController@grid')->name('features.grid');
                Route::resource('/features', 'FeatureController');

                Route::put('/photoGalleries/restore/{id}', 'PhotoGalleryController@restore')->name('photoGalleries.restore');
                Route::put('/photoGalleries/restore', 'PhotoGalleryController@restoreAll')->name('photoGalleries.restoreAll');
                Route::delete('/photoGalleries', 'PhotoGalleryController@destroyAll')->name('photoGalleries.destroyAll');
                Route::get('/photoGalleries/grid', 'PhotoGalleryController@grid')->name('photoGalleries.grid');
                Route::resource('/photoGalleries', 'PhotoGalleryController');

                Route::put('/testimonials/restore/{id}', 'TestimonialController@restore')->name('testimonials.restore');
                Route::put('/testimonials/restore', 'TestimonialController@restoreAll')->name('testimonials.restoreAll');
                Route::delete('/testimonials', 'TestimonialController@destroyAll')->name('testimonials.destroyAll');
                Route::get('/testimonials/grid', 'TestimonialController@grid')->name('testimonials.grid');
                Route::get('/testimonials/activeComment/{testimonial}', 'TestimonialController@activeComment')->name('testimonials.activeComment');
                Route::resource('/testimonials', 'TestimonialController');

                Route::put('/partners/restore/{id}', 'PartnerController@restore')->name('partners.restore');
                Route::put('/partners/restore', 'PartnerController@restoreAll')->name('partners.restoreAll');
                Route::delete('/partners', 'PartnerController@destroyAll')->name('partners.destroyAll');
                Route::get('/partners/grid', 'PartnerController@grid')->name('partners.grid');
                Route::resource('/partners', 'PartnerController');

                Route::put('/sections/restore/{id}', 'SectionController@restore')->name('sections.restore');
                Route::put('/sections/restore', 'SectionController@restoreAll')->name('sections.restoreAll');
                Route::delete('/sections', 'SectionController@destroyAll')->name('sections.destroyAll');
                Route::get('/sections/grid', 'SectionController@grid')->name('sections.grid');
                Route::resource('/sections', 'SectionController');

                Route::put('/packages/restore/{id}', 'PackageController@restore')->name('packages.restore');
                Route::put('/packages/restore', 'PackageController@restoreAll')->name('packages.restoreAll');
                Route::delete('/packages', 'PackageController@destroyAll')->name('packages.destroyAll');
                Route::get('/packages/grid', 'PackageController@grid')->name('packages.grid');
                Route::resource('/packages', 'PackageController');

                Route::put('/services/restore/{id}', 'ServiceController@restore')->name('services.restore');
                Route::put('/services/restore', 'ServiceController@restoreAll')->name('services.restoreAll');
                Route::delete('/services', 'ServiceController@destroyAll')->name('services.destroyAll');
                Route::get('/services/grid', 'ServiceController@grid')->name('services.grid');
                Route::resource('/services', 'ServiceController');

                Route::get('/policies/grid', 'PolicyController@grid')->name('policies.grid');
                Route::resource('/policies', 'PolicyController')->only(['index','edit', 'update']);



                // MEMBERS ROUTES
//                Route::put('/members/restore/{id}', 'MemberController@restore')->name('members.restore');
//                Route::put('/members/restore', 'MemberController@restoreAll')->name('members.restoreAll');
//                Route::delete('/members', 'MemberController@destroyAll')->name('members.destroyAll');
//                Route::get('/members/grid', 'MemberController@grid')->name('members.grid');
//                Route::get('/members/activeMember/{member}', 'MemberController@activeMember')->name('members.activeMember');
//                Route::get('/members/getState', 'MemberController@getState')->name('members.getState');
//                Route::resource('/members', 'MemberController');


                // NEWSLETTER ROUTES
                Route::put('/newsletters/restore/{id}', 'NewsletterController@restore')->name('newsletters.restore');
                Route::put('/newsletters/restore', 'NewsletterController@restoreAll')->name('newsletters.restoreAll');
                Route::delete('/newsletters', 'NewsletterController@destroyAll')->name('newsletters.destroyAll');
                Route::get('/newsletters/grid', 'NewsletterController@grid')->name('newsletters.grid');
                Route::get('/newsletters/mailsList', 'NewsletterController@mailsList')->name('newsletters.mailsList');
                Route::get('/newsletters/mailsListGrid', 'NewsletterController@mailsListGrid')->name('newsletters.mailsListGrid');
                Route::get('/newsletters/mailsListMore/{id}', 'NewsletterController@mailsListMore')->name('newsletters.mailsListMore');
                Route::resource('/newsletters', 'NewsletterController');

                // VISITOR MESSAGE ROUTES
                Route::put('/visitorMessages/restore/{id}', 'VisitorMessageController@restore')->name('visitorMessages.restore');
                Route::put('/visitorMessages/restore', 'VisitorMessageController@restoreAll')->name('visitorMessages.restoreAll');
                Route::delete('/visitorMessages', 'VisitorMessageController@destroyAll')->name('visitorMessages.destroyAll');
                Route::get('/visitorMessages/grid', 'VisitorMessageController@grid')->name('visitorMessages.grid');
                Route::resource('/visitorMessages', 'VisitorMessageController');

                // USER ROUTES
                Route::put('/users/restore/{id}', 'UserController@restore')->name('users.restore');
                Route::put('/users/restore', 'UserController@restoreAll')->name('users.restoreAll');
                Route::delete('/users', 'UserController@destroyAll')->name('users.destroyAll');
                Route::get('/users/grid', 'UserController@grid')->name('users.grid');
                Route::resource('/users', 'UserController');

                // SETTING ROUTES
//                Route::get('/settings', 'DashboardController@index')->name('admin_settings');
                Route::get('/settings', 'SettingController@index')->name('settings.index');
                Route::post('/settings', 'SettingController@store')->name('settings.store');
                Route::post('/modules-settings', 'SettingController@modules')->name('settings.modules');


            });  // End Role Routes


            Route::resource('/languages', 'LanguageController');
            // Route::post('/languages/{id}', 'LanguageController@update')->name('languages');

        }); // End Authenticated Admin routes
    }); // End Admin Routes

});
