<?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::get('addform/{data}','FetchController@addform');
            Route::get('editform/{data}','FetchController@editform');
            Route::get('deleteform/{data}','FetchController@deleteform');

			Route::post('/logout', 'LoginController@logout')->name('admin_logout');

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

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

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

                // Member 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::resource('/members', 'MemberController');

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

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

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

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

                // 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');
                
                // About 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');
                
                // Code ROUTES
                Route::put('/codes/restore/{id}', 'CodeController@restore')->name('codes.restore');
                Route::put('/codes/restore', 'CodeController@restoreAll')->name('codes.restoreAll');
                Route::delete('/codes', 'CodeController@destroyAll')->name('codes.destroyAll');
                Route::get('/codes/grid', 'CodeController@grid')->name('codes.grid');
                Route::resource('/codes', 'CodeController');
                
                // Partner 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');
                
                // Gallery ROUTES
                Route::put('/galleries/restore/{id}', 'GalleryController@restore')->name('galleries.restore');
                Route::put('/galleries/restore', 'GalleryController@restoreAll')->name('galleries.restoreAll');
                Route::delete('/galleries', 'GalleryController@destroyAll')->name('galleries.destroyAll');
                Route::get('/galleries/grid', 'GalleryController@grid')->name('galleries.grid');
                Route::resource('/galleries', 'GalleryController');
                // Mail 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');
                
                // 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');
                
                // Type ROUTES
                Route::put('/types/restore/{id}', 'TypeController@restore')->name('types.restore');
                Route::put('/types/restore', 'TypeController@restoreAll')->name('types.restoreAll');
                Route::delete('/types', 'TypeController@destroyAll')->name('types.destroyAll');
                Route::get('/types/grid', 'TypeController@grid')->name('types.grid');
                Route::resource('/types', 'TypeController');
                
                // Level ROUTES
                Route::put('/levels/restore/{id}', 'LevelController@restore')->name('levels.restore');
                Route::put('/levels/restore', 'LevelController@restoreAll')->name('levels.restoreAll');
                Route::delete('/levels', 'LevelController@destroyAll')->name('levels.destroyAll');
                Route::get('/levels/grid', 'LevelController@grid')->name('levels.grid');
                Route::resource('/levels', 'LevelController');
                
                
                
                // WbSetting ROUTES
                Route::put('/wbsettings/restore/{id}', 'WbSettingController@restore')->name('wbsettings.restore');
                Route::put('/wbsettings/restore', 'WbSettingController@restoreAll')->name('wbsettings.restoreAll');
                Route::delete('/wbsettings', 'WbSettingController@destroyAll')->name('wbsettings.destroyAll');
                Route::get('/wbsettings/grid', 'WbSettingController@grid')->name('wbsettings.grid');
                Route::resource('/wbsettings', 'WbSettingController');
                
                 // 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');


			});  // End Role Routes


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

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

});
