<?php

use Illuminate\Support\Facades\Route;
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
use Modules\Partner\Controllers\Admin\PartnerController;
use Modules\Country\Controllers\Admin\CountryController;
use Modules\Setting\Controllers\Admin\SettingController;
use Modules\Slider\Controllers\Admin\SliderController;
use Modules\Category\Controllers\Admin\CategoryController;
use Modules\User\Controllers\Admin\UserController;
use Modules\User\Controllers\Admin\MemberController;
use Modules\City\Controllers\Admin\CityController;
use Modules\Way\Controllers\Admin\WayController;
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\Order\Controllers\Admin\OrderController;
use Modules\Notification\Controllers\Admin\NotificationController;
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/item',[ProductController::class,'item'])->name('admin.item');
            Route::get('fetch/model',[CategoryController::class,'model'])->name('admin.model');
            Route::get('fetch/city',[ShippingController::class,'cities'])->name('admin.city');
            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);

                // Country ROUTES
                Route::put('/countries/restore/{id}', [CountryController::class,'restore'])->name('countries.restore');
                Route::put('/countries/restore', [CountryController::class,'restoreAll'])->name('countries.restoreAll');
                Route::delete('/countries', [CountryController::class,'destroyAll'])->name('countries.destroyAll');
                Route::get('/countries/grid', [CountryController::class,'grid'])->name('countries.grid');
                Route::resource('/countries', CountryController::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);

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

                // Way ROUTES
                Route::put('/ways/restore/{id}', [WayController::class,'restore'])->name('ways.restore');
                Route::put('/ways/restore', [WayController::class,'restoreAll'])->name('ways.restoreAll');
                Route::delete('/ways', [WayController::class,'destroyAll'])->name('ways.destroyAll');
                Route::get('/ways/grid', [WayController::class,'grid'])->name('ways.grid');
                Route::resource('/ways', WayController::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);

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

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

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

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

                // Country 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

});
