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

        Route::get('/photos/categories', 'PhotoController@categories')->name('photos_categories');
        Route::get('/photos/{category}/{slug?}', 'PhotoController@index')->name('photos');

        Route::get('/websites/categories', 'WebsiteController@categories')->name('websites_categories');
        Route::get('/websites/{category}/{slug?}', 'WebsiteController@index')->name('websites');

        Route::get('/videos/categories', 'VideoController@categories')->name('videos_categories');
        Route::get('/videos/{category}/{slug?}', 'VideoController@index')->name('videos');

        // Route::resource('userNewsletters', 'NewsletterController');
        // Route::resource('userVisitorMessages', 'VisitorMessageController');

    });



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

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

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

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

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

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

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

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

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

});
