<?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 App\Http\Middleware\CheckWebSiteEnabled;
use Illuminate\Support\Facades\Route;

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('index');
        Route::get('/pages/{pageName}', 'PageController@index')->name('pages');
        Route::get('/services/{service}', 'ServiceController@index')->name('ourService');
        Route::post('/contact-us', 'ContactController@store')->name('sendContactUs');
        Route::get('/newsletters', 'ContactController@newsletters')->name('newsletters');
        Route::post('/visitorRequest', 'ContactController@visitorRequest')->name('visitorRequest');
        Route::post('/careers', 'ContactController@careers')->name('careers');

    });



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

	/**
	* Authentication routes , and Authentication user routs
	*/
	Auth::routes();

//	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::post('/logout', 'LoginController@logout')->name('admin_logout');

			Route::group([ 'middleware' => ['checkRole']], function () {


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

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

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

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

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

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

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

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


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

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

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

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


			});  // End Role Routes


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

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

});
