<?php

use App\Http\Controllers\Web\HomeController;
use Illuminate\Support\Facades\Route;
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
use Modules\Gallery\Controllers\Web\GalleryController;
use Modules\Newsletter\Controllers\Web\NewsletterController;
use Modules\Order\Controllers\Web\OrderController;
use Modules\Package\Controllers\Web\PackageContoller;
use Modules\Page\Controllers\Web\PageController;
use Modules\Project\Controllers\Web\ProjectController;
use Modules\News\Controllers\Web\NewsController;
use Modules\Team\Controllers\Web\TeamController;
use Modules\Page\Controllers\Web\ContactController;
use Modules\Partner\Controllers\Web\PartnerContoller;
use Modules\Service\Controllers\Web\ServiceContoller;
use Modules\VisitorMessage\Controllers\Web\VisitorMessageController;

/*
  |--------------------------------------------------------------------------
  | 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!
  |
 */
Route::get('/', function () {
    return redirect(LaravelLocalization::getLocalizedURL(null, '/'));
});
//Route::get('language/{id}/{slug?}', 'LanguageController@details');
// dd(validatePhone('201011345595'));
Route::group(['prefix' => LaravelLocalization::setLocale()], function () {

    // Route::get('/coming', [PageController::class,'coming'])->name('web.coming');
    Route::group(['middleware' => ['checkWebSiteEnabled', 'WebsiteVisitorCount','AutoPage']], function () {
        //Home
        Route::get('/', [HomeController::class,'index'])->name('web.home');
        Route::get('/gallery', [GalleryController::class,'index'])->name('web.gallery');

        Route::get('/terms', [PageController::class,'terms'])->name('web.terms');
        Route::get('/conditions', [PageController::class,'conditions'])->name('web.conditions');
        Route::get('/about', [PageController::class,'about'])->name('web.about');
        Route::get('/projects', [ProjectController::class,'index'])->name('web.projects');
        Route::get('/news', [NewsController::class,'index'])->name('web.news');
        Route::get('/news/{id}', [NewsController::class,'show'])->name('web.news.show');
        Route::get('/team', [TeamController::class,'index'])->name('web.team');
        Route::get('/contact', [ContactController::class,'index'])->name('web.contact');

        Route::group(['prefix' => 'partner'], function () {
            Route::get('/', [PartnerContoller::class,'index'])->name('web.partners');
            Route::get('/{id}', [PartnerContoller::class,'show'])->name('web.partners.show');
        });

        Route::group(['prefix' => 'service'], function () {
            Route::get('/', [ServiceContoller::class,'index'])->name('web.services');
            Route::get('/{id}', [ServiceContoller::class,'show'])->name('web.services.show');
        });
        Route::get('package/{id}', [PackageContoller::class,'show'])->name('web.packages.show');


        Route::post('/newsletter', [NewsletterController::class,'newsletter'])->name('web.newsletter');
        Route::get('/newsletter', function () {
            abort(404);
        });
        Route::post('/contact-message', [VisitorMessageController::class,'store'])->name('web.contact.message');
        Route::group(['prefix' => 'order'], function () {
            Route::get('/times', [OrderController::class,'times'])->name('web.order.times');
            Route::get('/', [OrderController::class,'index'])->name('web.order');
            Route::post('/', [OrderController::class,'order'])->name('web.ordering');
        });

    });
});
