<?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;

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('page_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('article_details');

    });



	/**
	* 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::get('/addvision/{id}', 'FetchController@addvision');
                Route::get('/addmission/{id}', 'FetchController@addmission');

                Route::get('/type/{id}', 'FetchController@type');
			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');


                // reasons ROUTES
                Route::put('/reasons/restore/{id}', 'ReasonController@restore')->name('reasons.restore');
                Route::put('/reasons/restore', 'ReasonController@restoreAll')->name('reasons.restoreAll');
                Route::delete('/reasons', 'ReasonController@destroyAll')->name('reasons.destroyAll');
                Route::get('/reasons/grid', 'ReasonController@grid')->name('reasons.grid');
                Route::resource('/reasons', 'ReasonController');
                
                
                // mails ROUTES
                Route::put('/mails/restore/{id}', 'MailController@restore')->name('mails.restore');
                Route::put('/mails/restore', 'MailController@restoreAll')->name('mails.restoreAll');
                Route::delete('/mails', 'MailController@destroyAll')->name('mails.destroyAll');
                Route::get('/mails/grid', 'MailController@grid')->name('mails.grid');
                Route::resource('/mails', 'MailController');
                
                
                // contacts 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');
                
                
                // associations ROUTES
                Route::put('/associations/restore/{id}', 'AssociationController@restore')->name('associations.restore');
                Route::put('/associations/restore', 'AssociationController@restoreAll')->name('associations.restoreAll');
                Route::delete('/associations', 'AssociationController@destroyAll')->name('associations.destroyAll');
                Route::get('/associations/grid', 'AssociationController@grid')->name('associations.grid');
                Route::resource('/associations', 'AssociationController');
                
                
                // 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');
                
                
                
                // 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');
                
                
                
                // methods ROUTES
                Route::put('/methods/restore/{id}', 'MethodController@restore')->name('methods.restore');
                Route::put('/methods/restore', 'MethodController@restoreAll')->name('methods.restoreAll');
                Route::delete('/methods', 'MethodController@destroyAll')->name('methods.destroyAll');
                Route::get('/methods/grid', 'MethodController@grid')->name('methods.grid');
                Route::resource('/methods', 'MethodController');
                
                
                // 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::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');
                
                // holds ROUTES
                Route::put('/holds/restore/{id}', 'HoldController@restore')->name('holds.restore');
                Route::put('/holds/restore', 'HoldController@restoreAll')->name('holds.restoreAll');
                Route::delete('/holds', 'HoldController@destroyAll')->name('holds.destroyAll');
                Route::get('/holds/grid', 'HoldController@grid')->name('holds.grid');
                Route::resource('/holds', 'HoldController');
                
                
                // offlines ROUTES
                Route::put('/offlines/restore/{id}', 'OfflineController@restore')->name('offlines.restore');
                Route::put('/offlines/restore', 'OfflineController@restoreAll')->name('offlines.restoreAll');
                Route::delete('/offlines', 'OfflineController@destroyAll')->name('offlines.destroyAll');
                Route::get('/offlines/grid', 'OfflineController@grid')->name('offlines.grid');
                Route::resource('/offlines', 'OfflineController');
                
                

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

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

});
