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


        // newsletter and contact us routes
        Route::get('/contact-us', 'VisitorMessageController@index')->name('contact_us');
        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('service', 'ServiceController@index')->name('service.index');
        Route::get('staff/{staff}', 'StaffController@show')->name('staff.show');
        Route::get('blog', 'BlogController@index')->name('blog.index');
        Route::get('blog/{blog}', 'BlogController@show')->name('blog.show');
        Route::get('job', 'JobController@index')->name('job.index');
        Route::post('job', 'JobController@store')->name('job.store');
        Route::get('consultation', 'ConsultationController@index')->name('consultation.index');
        Route::post('consultation', 'ConsultationController@store')->name('consultation.store');

    });


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

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

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

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

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

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

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

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

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

                // JOBS ROUTES
                Route::put('/jobs/restore/{id}', 'JobController@restore')->name('jobs.restore');
                Route::put('/jobs/restore', 'JobController@restoreAll')->name('jobs.restoreAll');
                Route::delete('/jobs', 'JobController@destroyAll')->name('jobs.destroyAll');
                Route::get('/jobs/grid', 'JobController@grid')->name('jobs.grid');
                Route::get('/jobs/report', 'ReportController@jobsReport')->name('jobs.report');
                Route::resource('/jobs', 'JobController')->only(['index', 'edit', 'destroy']);

                // CONSULTATIONS ROUTES
                Route::put('/consultations/restore/{id}', 'ConsultationController@restore')->name('consultations.restore');
                Route::put('/consultations/restore', 'ConsultationController@restoreAll')->name('consultations.restoreAll');
                Route::delete('/consultations', 'ConsultationController@destroyAll')->name('consultations.destroyAll');
                Route::get('/consultations/grid', 'ConsultationController@grid')->name('consultations.grid');
                Route::get('/consultations/report', 'ReportController@consultationsReport')->name('consultations.report');
                Route::resource('/consultations', 'ConsultationController')->only(['index', 'edit', 'destroy']);


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


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

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

                // 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')->only(['index', 'edit', 'update']);

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

                // 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::get('/newsletters/report', 'ReportController@newslettersReport')->name('newsletters.report');
                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

});
