<?php

use Illuminate\Support\Facades\Route;
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
use Modules\Area\Controllers\Admin\AreaController;
use Modules\Option\Controllers\Admin\OptionController;

use Modules\Store\Controllers\Admin\StoreController;
use Modules\Store\Controllers\Admin\EditStoreController;
use Modules\Store\Controllers\Admin\BranchController;

use Modules\User\Controllers\Admin\UserController;
use Modules\User\Controllers\Admin\MemberController;
use Modules\User\Controllers\Admin\ProviderController;


use Modules\Notification\Controllers\Admin\AlertController;
use Modules\Notification\Controllers\Admin\NotificationController;

use Modules\Faq\Controllers\Admin\FaqController;
use Modules\Review\Controllers\Admin\ReviewController;
use Modules\Setting\Controllers\Admin\SettingController;
use Modules\Slider\Controllers\Admin\SliderController;
use Modules\Category\Controllers\Admin\CategoryController;
use Modules\City\Controllers\Admin\CityController;
use Modules\Package\Controllers\Admin\PackageController;
use Modules\Shipping\Controllers\Admin\ShippingController;
use Modules\Product\Controllers\Admin\ProductController;
use Modules\Coupon\Controllers\Admin\CouponController;
use Modules\Rate\Controllers\Admin\RateController;
use Modules\Complaint\Controllers\Admin\ComplaintController;
use Modules\Subscribe\Controllers\Admin\SubscribeController;
use Modules\Order\Controllers\Admin\OrderController;
use Modules\Page\Controllers\Admin\PageController;
use Modules\NewsLetter\Controllers\Admin\NewsLetterController;
use Modules\VisitorMessage\Controllers\Admin\VisitorMessageController;

/*
|--------------------------------------------------------------------------
| 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;

/**
 * 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');
    /**
     * Web Routes
     */
    Route::group([ 'prefix'=> 'admin' ], function () {
        Route::group(['namespace' => 'App\Http\Controllers\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::get('/dashboard/stats', 'DashboardController@stats')->name('dashboard.stats');
                Route::get('/dashboard/add/dates', 'WorkDayController@addDate')->name('dashboard.add_date');
            });
        });

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

            Route::get('fetch/size',[ProductController::class,'size'])->name('admin.size');
            Route::get('fetch/color',[ProductController::class,'color'])->name('admin.color');
            Route::get('fetch/item',[ProductController::class,'item'])->name('admin.item');
            Route::get('fetch/item/key',[ProductController::class,'itemKey'])->name('admin.item.key');
            Route::get('fetch/model',[CategoryController::class,'model'])->name('admin.model');
            Route::get('fetch/city',[ShippingController::class,'cities'])->name('admin.city');
            Route::get('fetch/country/cities',[CityController::class,'citiesByCountry'])->name('admin.country.cities');
            Route::get('fetch/product',[CouponController::class,'products'])->name('admin.search_products');

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

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

                // Member ROUTES
                Route::put('/members/restore/{id}', [MemberController::class,'restore'])->name('members.restore');
                Route::put('/members/restore', [MemberController::class,'restoreAll'])->name('members.restoreAll');
                Route::delete('/members', [MemberController::class,'destroyAll'])->name('members.destroyAll');
                Route::get('/members/grid', [MemberController::class,'grid'])->name('members.grid');
                Route::resource('/members', MemberController::class);

                // Providers ROUTES
                Route::put('/providers/restore/{id}', [ProviderController::class,'restore'])->name('providers.restore');
                Route::put('/providers/restore', [ProviderController::class,'restoreAll'])->name('providers.restoreAll');
                Route::delete('/providers', [ProviderController::class,'destroyAll'])->name('providers.destroyAll');
                Route::get('/providers/grid', [ProviderController::class,'grid'])->name('providers.grid');
                Route::resource('/providers', ProviderController::class);

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

                // Area ROUTES
                Route::put('/areas/restore/{id}', [AreaController::class,'restore'])->name('areas.restore');
                Route::put('/areas/restore', [AreaController::class,'restoreAll'])->name('areas.restoreAll');
                Route::delete('/areas', [AreaController::class,'destroyAll'])->name('areas.destroyAll');
                Route::get('/areas/grid', [AreaController::class,'grid'])->name('areas.grid');
                Route::resource('/areas', AreaController::class);

                // Faq ROUTES
                Route::put('/faqs/restore/{id}', [FaqController::class,'restore'])->name('faqs.restore');
                Route::put('/faqs/restore', [FaqController::class,'restoreAll'])->name('faqs.restoreAll');
                Route::delete('/faqs', [FaqController::class,'destroyAll'])->name('faqs.destroyAll');
                Route::get('/faqs/grid', [FaqController::class,'grid'])->name('faqs.grid');
                Route::resource('/faqs', FaqController::class);

                // Store ROUTES
                Route::put('/stores/restore/{id}', [StoreController::class,'restore'])->name('stores.restore');
                Route::put('/stores/restore', [StoreController::class,'restoreAll'])->name('stores.restoreAll');
                Route::delete('/stores', [StoreController::class,'destroyAll'])->name('stores.destroyAll');
                Route::get('/stores/grid', [StoreController::class,'grid'])->name('stores.grid');
                Route::resource('/stores', StoreController::class);

                // EditStore ROUTES
                Route::put('/edit_stores/restore/{id}', [EditStoreController::class,'restore'])->name('edit_stores.restore');
                Route::put('/edit_stores/restore', [EditStoreController::class,'restoreAll'])->name('edit_stores.restoreAll');
                Route::delete('/edit_stores', [EditStoreController::class,'destroyAll'])->name('edit_stores.destroyAll');
                Route::get('/edit_stores/grid', [EditStoreController::class,'grid'])->name('edit_stores.grid');
                Route::resource('/edit_stores', EditStoreController::class);

                // Branch ROUTES
                Route::put('/branches/restore/{id}', [BranchController::class,'restore'])->name('branches.restore');
                Route::put('/branches/restore', [BranchController::class,'restoreAll'])->name('branches.restoreAll');
                Route::delete('/branches', [BranchController::class,'destroyAll'])->name('branches.destroyAll');
                Route::get('/branches/grid', [BranchController::class,'grid'])->name('branches.grid');
                Route::resource('/branches', BranchController::class);

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

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

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

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

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

                // Option ROUTES
                Route::put('/options/restore/{id}', [OptionController::class,'restore'])->name('options.restore');
                Route::put('/options/restore', [OptionController::class,'restoreAll'])->name('options.restoreAll');
                Route::delete('/options', [OptionController::class,'destroyAll'])->name('options.destroyAll');
                Route::get('/options/grid', [OptionController::class,'grid'])->name('options.grid');
                Route::resource('/options', OptionController::class);

                // Coupon ROUTES
                Route::put('/coupons/restore/{id}', [CouponController::class,'restore'])->name('coupons.restore');
                Route::put('/coupons/restore', [CouponController::class,'restoreAll'])->name('coupons.restoreAll');
                Route::delete('/coupons', [CouponController::class,'destroyAll'])->name('coupons.destroyAll');
                Route::get('/coupons/grid', [CouponController::class,'grid'])->name('coupons.grid');
                Route::resource('/coupons', CouponController::class);

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

                // Complaint ROUTES
                Route::put('/complaints/restore/{id}', [ComplaintController::class,'restore'])->name('complaints.restore');
                Route::put('/complaints/restore', [ComplaintController::class,'restoreAll'])->name('complaints.restoreAll');
                Route::delete('/complaints', [ComplaintController::class,'destroyAll'])->name('complaints.destroyAll');
                Route::get('/complaints/grid', [ComplaintController::class,'grid'])->name('complaints.grid');
                Route::resource('/complaints', ComplaintController::class);

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

                // Subscribe
                Route::get('/subscribes/grid', [SubscribeController::class,'grid'])->name('subscribes.grid');
                Route::resource('/subscribes', SubscribeController::class)->only('index','edit');

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

                // Alert ROUTES
                Route::put('/alerts/restore/{id}', [AlertController::class,'restore'])->name('alerts.restore');
                Route::put('/alerts/restore', [AlertController::class,'restoreAll'])->name('alerts.restoreAll');
                Route::delete('/alerts', [AlertController::class,'destroyAll'])->name('alerts.destroyAll');
                Route::get('/alerts/grid', [AlertController::class,'grid'])->name('alerts.grid');
                Route::resource('/alerts', AlertController::class);

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

                // NewsLetter ROUTES
                Route::put('/newsletters/restore/{id}', [NewsLetterController::class,'restore'])->name('newsletters.restore');
                Route::put('/newsletters/restore', [NewsLetterController::class,'restoreAll'])->name('newsletters.restoreAll');
                Route::delete('/newsletters', [NewsLetterController::class,'destroyAll'])->name('newsletters.destroyAll');
                Route::get('/newsletters/grid', [NewsLetterController::class,'grid'])->name('newsletters.grid');
                Route::resource('/newsletters', NewsLetterController::class);

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

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

                // SETTING ROUTES
                Route::get('/settings', [SettingController::class,'index'])->name('settings.index');
                Route::post('/settings',  [SettingController::class,'store'])->name('settings.store');
                Route::post('/Modules-settings', [SettingController::class,'Modules'])->name('settings.Modules');

            });  // End Role Routes


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

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

});
