<?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 RouteServiceSlider 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('products/addfeature', 'ProductController@addfeature');
            Route::get('products/addfeatureDetail', 'ProductController@addfeatureDetail');

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

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

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

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

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

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

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

                // Gallery ROUTES
                Route::get('/galleries/grid', 'GalleryController@grid')->name('galleries.grid');
                Route::resource('/galleries', 'GalleryController')->only('index','edit','update');

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

});
