<?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 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('/', function () {
//        return redirect('/admin/login');
//    });

    Route::group(['namespace' => 'Web','middleware' => [ 'checkWebSiteEnabled', 'WebsiteVisitorCount'] ], function () {
        Route::get('/', 'HomeController@index')->name('home');

        Route::get('/products', 'ProductController@index')->name('ourProduct');

        Route::get('who-we-ar', 'AboutUsController@index')->name('aboutUs');

        Route::get('/get-in-touch', 'VisitorMessageController@index')->name('contact.index');
        Route::post('/contact-us', 'VisitorMessageController@store')->name('contact.store');

        Route::get('pages/{type}', 'PageController@index')->name('terms_privacy_accessibility');

    });


    /**
     * 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 () {

                // 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')->only(['index', 'edit', 'update']);

                // FLAVOR TYPES ROUTES
                Route::put('/flavorTypes/restore/{id}', 'FlavorTypeController@restore')->name('flavorTypes.restore');
                Route::put('/flavorTypes/restore', 'FlavorTypeController@restoreAll')->name('flavorTypes.restoreAll');
                Route::delete('/flavorTypes', 'FlavorTypeController@destroyAll')->name('flavorTypes.destroyAll');
                Route::get('/flavorTypes/grid', 'FlavorTypeController@grid')->name('flavorTypes.grid');
                Route::resource('/flavorTypes', 'FlavorTypeController');

                // ARTICLE ROUTES => flavors
                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');

//                // VIDEOS CATEGORIES ROUTES
//                Route::put('/videoCategories/restore/{id}', 'VideoCategoryController@restore')->name('videoCategories.restore');
//                Route::put('/videoCategories/restore', 'VideoCategoryController@restoreAll')->name('videoCategories.restoreAll');
//                Route::delete('/videoCategories', 'VideoCategoryController@destroyAll')->name('videoCategories.destroyAll');
//                Route::get('/videoCategories/grid', 'VideoCategoryController@grid')->name('videoCategories.grid');
//                Route::resource('/videoCategories', 'VideoCategoryController');
//
//                // VIDEOS ROUTES
//                Route::put('/videos/restore/{id}', 'VideoController@restore')->name('videos.restore');
//                Route::put('/videos/restore', 'VideoController@restoreAll')->name('videos.restoreAll');
//                Route::delete('/videos', 'VideoController@destroyAll')->name('videos.destroyAll');
//                Route::get('/videos/grid', 'VideoController@grid')->name('videos.grid');
//                Route::resource('/videos', 'VideoController');

                // PHOTOCATEGORIES ROUTES => Delivery Companies
//                Route::put('/photoCategories/restore/{id}', 'PhotoCategoryController@restore')->name('photoCategories.restore');
//                Route::put('/photoCategories/restore', 'PhotoCategoryController@restoreAll')->name('photoCategories.restoreAll');
//                Route::delete('/photoCategories', 'PhotoCategoryController@destroyAll')->name('photoCategories.destroyAll');
                Route::get('/photoCategories/grid', 'PhotoCategoryController@grid')->name('photoCategories.grid');
                Route::resource('/photoCategories', 'PhotoCategoryController')->only(['index', 'edit', 'update']);

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

//                // WEBSITE GALLERY ROUTES
//                Route::put('/websiteCategories/restore/{id}', 'WebsiteCategoryController@restore')->name('websiteCategories.restore');
//                Route::put('/websiteCategories/restore', 'WebsiteCategoryController@restoreAll')->name('websiteCategories.restoreAll');
//                Route::delete('/websiteCategories', 'WebsiteCategoryController@destroyAll')->name('websiteCategories.destroyAll');
//                Route::get('/websiteCategories/grid', 'WebsiteCategoryController@grid')->name('websiteCategories.grid');
//                Route::resource('/websiteCategories', 'WebsiteCategoryController');

                // SLIDERS 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::get('/sliders/banner', 'SliderController@bannerIndex')->name('sliders.bannerIndex');
                Route::get('/sliders/bannerGrid', 'SliderController@bannerGrid')->name('sliders.bannerGrid');
                Route::resource('/sliders', 'SliderController');

                // 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')->only(['index', 'edit', 'update']);

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

});
