<?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\Http\Middleware\CheckWebSiteEnabled;

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

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

    // Route::get('/', function () {
    //     // return redirect('/admin/login');
    // });
    Route::group(['prefix' => 'laravel-filemanager', 'middleware' => ['web', 'admin_auth']], function () {
        \UniSharp\LaravelFilemanager\Lfm::routes();
    });



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


    Route::get('/home', 'HomeController@index')->name('home');
    /**
     * 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::get('/cobons/user', 'CobonController@userFilter');
            Route::get('/cobons/product', 'CobonController@productFilter');
            Route::get('/attributes/addChoice', 'AttributeController@addChoice');
            Route::get('/addlink', 'FetchController@addlink');
            Route::get('/attributes/choices', 'AttributeController@choices');
            Route::get('/shippings/addCity', 'ShippingController@addCity');
            Route::get('/country', 'FetchController@country');
            Route::get('/attribute', 'FetchController@attribute');
            Route::get('/addrate', 'FetchController@addrate');
            Route::get('/birth', 'FetchController@birth')->name('admin.birth');
            Route::get('/subAttr', 'CategoryController@subAttr')->name('admin.subAttr');

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

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


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

                // Member 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::resource('/members', 'MemberController');

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

            });  // End Role Routes


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

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

});
