<?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('/pages', 'PageController@index')->name('pages');
        Route::get('/pages/{page}/{slug?}', 'PageController@details')->name('pages.details');

        Route::get('/articles/categories', 'ArticleController@categories')->name('articles.categories');
        Route::get('/articles/{category}/{slug?}', 'ArticleController@index')->name('articles');
        Route::get('/article/{article}/{slug?}', 'ArticleController@details')->name('articles.details');

        Route::get('/photos/categories', 'PhotoController@categories')->name('photos.categories');
        Route::get('/photos/{category}/{slug?}', 'PhotoController@index')->name('photos');

        Route::get('/websites/categories', 'WebsiteController@categories')->name('websites.categories');
        Route::get('/websites/{category}/{slug?}', 'WebsiteController@index')->name('websites');

        Route::get('/videos/categories', 'VideoController@categories')->name('videos.categories');
        Route::get('/videos/{category}/{slug?}', 'VideoController@index')->name('videos');

        Route::get('/contact-us', 'VisitorMessageController@index')->name('contact_us');
        Route::post('/contact-us', 'VisitorMessageController@store')->name('send_contact_us');

        Route::post('/newsletter', 'NewsletterController@store')->name('newsletter');

    });


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

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

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

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

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

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

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


                // NEW ROUTES

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

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

                // CAREERS ROUTES
                Route::put('/careers/restore/{id}', 'CareerController@restore')->name('careers.restore');
                Route::put('/careers/restore', 'CareerController@restoreAll')->name('careers.restoreAll');
                Route::delete('/careers', 'CareerController@destroyAll')->name('careers.destroyAll');
                Route::get('/careers/grid', 'CareerController@grid')->name('careers.grid');
                Route::resource('/careers', 'CareerController')->except(['create', 'store']);

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

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

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

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

                // MEMBERS 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::get('/members/activeMember/{member}', 'MemberController@activeMember')->name('members.activeMember');
                Route::get('/members/getCityAndSector', 'MemberController@getCityAndSector')->name('members.getCityAndSector');
                Route::resource('/members', 'MemberController');

                // PARTNERS ROUTES
                Route::put('/partners/restore/{id}', 'PartnerController@restore')->name('partners.restore');
                Route::put('/partners/restore', 'PartnerController@restoreAll')->name('partners.restoreAll');
                Route::delete('/partners', 'PartnerController@destroyAll')->name('partners.destroyAll');
                Route::get('/partners/details', 'PartnerController@details')->name('partners.details');
                Route::post('/partners/details/{partnerDetail}', 'PartnerController@updateDetails')->name('partners.updateDetails');
                Route::get('/partners/grid', 'PartnerController@grid')->name('partners.grid');
                Route::resource('/partners', 'PartnerController');

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


                // PROJECTS ROUTES
                Route::put('/projects/restore/{id}', 'ProjectController@restore')->name('projects.restore');
                Route::put('/projects/restore', 'ProjectController@restoreAll')->name('projects.restoreAll');
                Route::delete('/projects', 'ProjectController@destroyAll')->name('projects.destroyAll');
                Route::get('/projects/grid', 'ProjectController@grid')->name('projects.grid');
                Route::get('/projects/details', 'ProjectController@details')->name('projects.details');
                Route::post('/projects/details/{projectDetail}', 'ProjectController@updateDetails')->name('projects.updateDetails');
                Route::get('/projects/grid', 'ProjectController@grid')->name('projects.grid');
                Route::resource('/projects', 'ProjectController');

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

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

                // UNITS ROUTES
                Route::put('/units/restore/{id}', 'UnitController@restore')->name('units.restore');
                Route::put('/units/restore', 'UnitController@restoreAll')->name('units.restoreAll');
                Route::delete('/units', 'UnitController@destroyAll')->name('units.destroyAll');
                Route::get('/units/grid', 'UnitController@grid')->name('units.grid');
                Route::resource('/units', 'UnitController')->only(['index', 'edit', 'destroy']);

                // PACKAGE CATEGORIES ROUTES
                Route::put('/packageCategories/restore/{id}', 'PackageCategoryController@restore')->name('packageCategories.restore');
                Route::put('/packageCategories/restore', 'PackageCategoryController@restoreAll')->name('packageCategories.restoreAll');
                Route::delete('/packageCategories', 'PackageCategoryController@destroyAll')->name('packageCategories.destroyAll');
                Route::get('/packageCategories/grid', 'PackageCategoryController@grid')->name('packageCategories.grid');
                Route::resource('/packageCategories', 'PackageCategoryController');

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



            }); // End Role Routes


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

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

});
