<?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('/privacy-policy', 'HomeController@privacyPolicy')->name('privacyPolicy');
//        Route::get('/terms-conditions', 'HomeController@termsConditions')->name('termsConditions');
//
//
//        // newsletter and contact us routes
//        Route::get('/contact-us', 'VisitorMessageController@index')->name('contactUs');
//        Route::post('/contact-us', 'VisitorMessageController@store')->name('send_contact_us');
//        Route::get('about-us', 'AboutUsController@index')->name('aboutUs');
//        Route::post('/newsletter', 'NewsletterController@store')->name('newsletter');
//
//
//        Route::get('/login/', 'LoginController@login')->name('userProvider.login');
//        Route::post('/login', 'LoginController@doLogin')->name('userProvider.doLogin');
//
//        Route::get('/register', 'UserController@register')->name('user.register');
//        Route::post('/register', 'UserController@doRegister')->name('user.doRegister');
//        Route::get('/getState', 'UserController@getState')->name('user.getState');
//
//        Route::get('/provider/register', 'ProviderController@register')->name('provider.register');
//        Route::post('/provider/register', 'ProviderController@doRegister')->name('provider.doRegister');
//        Route::get('/getCityAndSector', 'ProviderController@getCityAndSector')->name('provider.getCityAndSector');
//
//
//        Route::get('/forget-password', 'ResetPasswordController@forgetPasswordForm')->name('user.forgetPassword');
//        Route::post('/send-forget-password-code', 'ResetPasswordController@sendForgetPasswordCode')->name('user.sendForgetPasswordCode');
//        Route::get('/type-forget-password-code', 'ResetPasswordController@typeForgetPasswordCode')->name('user.typeForgetPasswordCode');
//        Route::post('/code-verification', 'ResetPasswordController@codeVerification')->name('user.codeVerification');
//        Route::get('/new-password', 'ResetPasswordController@newPasswordForm')->name('user.newPasswordForm');
//        Route::post('/resetPassword', 'ResetPasswordController@resetPassword')->name('user.resetPassword');
//
//        Route::get('/hotel', 'HotelController@index')->name('hotel.index');
//        Route::get('/hotel/{hotel}', 'HotelController@show')->name('hotel.show');
//        Route::get('/hotel-offer', 'HotelController@offerHall')->name('hotel.offerHall');
//        Route::get('/reservation-details/{hotel}', 'ReservationController@reservationDetails')->name('reservation.reservationDetails');
//


//        Route::group(['middleware' => 'RedirectToPreviousLink'], function () {
//            Route::group(['middleware' => 'UserAuth'], function (){
//
//                Route::post('/storeDeviceToken', 'LoginController@storeDeviceToken')->name('userProvider.storeDeviceToken');
//
//
//                Route::any('/logout', 'LoginController@logout')->name('userProvider.logout');
//                Route::get('/user/profile', 'UserController@index')->name('user.profile');
//                Route::post('/userUpdateProfile/{user}', 'UserController@updateProfile')->name('user.updateProfile');
//                Route::get('/userReservationSearch', 'UserController@reservationSearch')->name('user.reservationSearch');
//                Route::get('/reservation/{reservation}', 'ReservationController@reservationDetails')->name('reservation.reservationDetails');
////                Route::get('/delete-reservation/{reservation}', 'ReservationController@cancelReservation')->name('reservation.cancelReservation');
//                Route::post('/reservation-invitation/{reservationId}', 'ReservationController@invitation')->name('reservation.invitation');
//
//                Route::get('/provider/profile', 'ProviderController@index')->name('provider.profile');
//                Route::post('/providerUpdateProfile/{user}', 'ProviderController@updateProfile')->name('provider.updateProfile');
//                Route::get('/providerWalletSearch', 'ProviderController@walletSearch')->name('provider.walletSearch');
//                Route::post('/providerReservationSearch', 'ProviderController@reservationSearch')->name('provider.reservationSearch');
//                Route::get('/provider/delete-hotel/{hotel_id}', 'ProviderController@deleteHall')->name('provider.deleteHall');
//                Route::get('/provider/edit-hotel/{hotel}', 'ProviderController@editHall')->name('provider.editHall');
//                Route::post('/provider/addEditHall/{hotel?}', 'ProviderController@AddEditHall')->name('provider.AddEditHall');
//
//
//                Route::get('/reservationStatusOperation{reservation}', 'ReservationController@reservationStatusOperation')->name('reservation.reservationStatusOperation');
//
//                Route::post('hotel-evaluate', 'UserController@hotelEvaluate')->name('hotelEvaluate');
//
//                // ######################################################
//                Route::get('/user/markAsRead', 'UserController@markAsRead')->name('user.markAsRead');
//                Route::get('user/refreshNotification', 'UserController@refreshNotification')->name('user.refreshNotification');
//                Route::get('/hotel-reservation/{hotel}', 'ReservationController@reservationPage')->name('reservation.hotelReservation');
//                Route::post('/reservation/{hotel}', 'ReservationController@addReservation')->name('reservation.addReservation');
//                Route::get('reservation-pay-now/{reservation}', 'ReservationController@payNow')->name('reservation.payNow');
//                Route::get('reservation-send-request/{reservation}', 'ReservationController@sendReservationRequest')->name('reservation.sendReservationRequest');
//
//                Route::post('reservation-finishPay/{reservation}', 'MyFatoorah@pay')->name('reservation.finishPay');
//                Route::get('callback', 'MyFatoorah@callback')->name('callback');
//
//            });
//        });

    });


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


                // HALLS 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::get('/hotels/getCityAndSector', 'HotelController@getCityAndSector')->name('hotels.getCityAndSector');
                Route::get('/hotels/activeHall/{hotel}', 'HotelController@activeHall')->name('hotels.activeHall');
                Route::resource('/hotels', 'HotelController');

                // HALLS ROUTES
                Route::put('/hotel_reservations/restore/{id}', 'HotelReservationController@restore')->name('hotel_reservations.restore');
                Route::put('/hotel_reservations/restore', 'HotelReservationController@restoreAll')->name('hotel_reservations.restoreAll');
                Route::delete('/hotel_reservations', 'HotelReservationController@destroyAll')->name('hotel_reservations.destroyAll');
                Route::get('/hotel_reservations/grid', 'HotelReservationController@grid')->name('hotel_reservations.grid');
//                Route::get('/hotel_reservations/activeHall/{hotel}', 'HotelReservationController@activeHall')->name('hotel_reservations.activeHall');
                Route::resource('/hotel_reservations', 'HotelReservationController')->only(['index', 'edit', 'destroy']);
                Route::get('/hotel_reservations-reports', 'ReportController@hotelReservationsReport')->name('hotel_reservations.reports');

                // PACKAGES 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::get('/packages/getCity', 'PackageController@getCities')->name('packages.getCities');
                Route::get('/packages/activePackage/{package}', 'PackageController@activePackage')->name('packages.activePackage');
                Route::resource('/packages', 'PackageController')->only(['index', 'edit', 'update']);

                // PARTNERS ROUTES
                Route::put('/package_reservations/restore/{id}', 'PackageReservationController@restore')->name('package_reservations.restore');
                Route::put('/package_reservations/restore', 'PackageReservationController@restoreAll')->name('package_reservations.restoreAll');
                Route::delete('/package_reservations', 'PackageReservationController@destroyAll')->name('package_reservations.destroyAll');
                Route::get('/package_reservations/grid', 'PackageReservationController@grid')->name('package_reservations.grid');
                Route::resource('/package_reservations', 'PackageReservationController')->only(['index', 'edit', 'destroy']);
                Route::get('/package_reservations-reports', 'ReportController@packageReservationsReport')->name('package_reservations.reports');

                // FLIGHTS ROUTES
                Route::put('/flights/restore/{id}', 'FlightController@restore')->name('flights.restore');
                Route::put('/flights/restore', 'FlightController@restoreAll')->name('flights.restoreAll');
                Route::delete('/flights', 'FlightController@destroyAll')->name('flights.destroyAll');
                Route::get('/flights/grid', 'FlightController@grid')->name('flights.grid');
                Route::resource('/flights', 'FlightController')->except(['create', 'store', 'update']);
                Route::get('/flights-reports', 'ReportController@flightsReport')->name('flights.reports');


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

                // BANKS ACCOUNTS ROUTES
                Route::put('/banks/restore/{id}', 'BankController@restore')->name('banks.restore');
                Route::put('/banks/restore', 'BankController@restoreAll')->name('banks.restoreAll');
                Route::delete('/banks', 'BankController@destroyAll')->name('banks.destroyAll');
                Route::get('/banks/grid', 'BankController@grid')->name('banks.grid');
                Route::resource('/banks', 'BankController');

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

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

                // SLIDER 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::resource('/sliders', 'SliderController');


                // USERS NOTIFICATIONS ROUTES
                Route::put('/usersNotifications/restore/{id}', 'UsersNotificationController@restore')->name('usersNotifications.restore');
                Route::put('/usersNotifications/restore', 'UsersNotificationController@restoreAll')->name('usersNotifications.restoreAll');
                Route::delete('/usersNotifications', 'UsersNotificationController@destroyAll')->name('usersNotifications.destroyAll');
                Route::get('/usersNotifications/grid', 'UsersNotificationController@grid')->name('usersNotifications.grid');
                Route::get('/usersNotifications/getUsers', 'UsersNotificationController@getUsers')->name('usersNotifications.getUsers');
//                Route::get('/usersNotifications/getInstructors', 'UsersNotificationController@getInstructors')->name('usersNotifications.getInstructors');
                Route::resource('/usersNotifications', 'UsersNotificationController');


                // COURSE COMMENTS ROUTES
                Route::put('/comments/restore/{id}', 'CommentController@restore')->name('comments.restore');
                Route::put('/comments/restore', 'CommentController@restoreAll')->name('comments.restoreAll');
                Route::delete('/comments', 'CommentController@destroyAll')->name('comments.destroyAll');
                Route::get('/comments/grid', 'CommentController@grid')->name('comments.grid');
                Route::get('/comments/activeComment/{comment}', 'CommentController@activeComment')->name('comments.activeComment');
                Route::resource('/comments', 'CommentController')->only(['index', 'edit', 'destroy']);

                // 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/grid', 'PartnerController@grid')->name('partners.grid');
                Route::resource('/partners', 'PartnerController');

                // PAGES ROUTES
                Route::get('/policies/grid', 'PolicyController@grid')->name('policies.grid');
                Route::resource('/policies', 'PolicyController')->only(['index','edit', 'update']);

                // ABOUTS ROUTES
                Route::get('/abouts/grid', 'AboutController@grid')->name('abouts.grid');
                Route::resource('/abouts', 'AboutController')->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', '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');


            });  // End Role Routes


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

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

});
