<?php

use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Session;

use App\Http\Controllers\BackEndBladeExtractController;
use App\Http\Controllers\FrontEndBladeExtractController;

use App\Http\Controllers\Front\FrontController;
use App\Http\Controllers\Admin\AdminController;
use App\Http\Controllers\Admin\AdminSettingController;
use App\Http\Controllers\Admin\AdminSliderController;
use App\Http\Controllers\Admin\AdminServiceController;
use App\Http\Controllers\Admin\AdminPortfolioController;
use App\Http\Controllers\Admin\AdminTeamMemberController;
use App\Http\Controllers\Admin\AdminTestimonialController;
use App\Http\Controllers\Admin\AdminFaqController;
use App\Http\Controllers\Admin\AdminPostCategoryController;
use App\Http\Controllers\Admin\AdminPostController;
use App\Http\Controllers\Admin\AdminPricingPlanController;
use App\Http\Controllers\Admin\AdminSubscriberController;
use App\Http\Controllers\Admin\AdminHomePageItemController;
use App\Http\Controllers\Admin\AdminOtherPageItemController;
use App\Http\Controllers\Admin\AdminMenuController;
use App\Http\Controllers\Admin\AdminClientController;
use App\Http\Controllers\Admin\AdminTranslationController;


Route::middleware('check_home_session')->group(function () {
    Route::get('/', [FrontController::class, 'home'])->name('home');
    Route::get('/about', [FrontController::class, 'about'])->name('about');
    Route::get('/services', [FrontController::class, 'services'])->name('services');
    Route::get('/service/{slug}', [FrontController::class, 'service'])->name('service');
    Route::get('/portfolios', [FrontController::class, 'portfolios'])->name('portfolios');
    Route::get('/portfolio/{slug}', [FrontController::class, 'portfolio'])->name('portfolio');
    Route::get('/team-members', [FrontController::class, 'team_members'])->name('team_members');
    Route::get('/team-member/{slug}', [FrontController::class, 'team_member'])->name('team_member');
    Route::post('/team-member/send-message', [FrontController::class, 'team_member_send_message'])->name('team_member_send_message');
    Route::get('/testimonials', [FrontController::class, 'testimonials'])->name('testimonials');
    Route::get('/faq', [FrontController::class, 'faqs'])->name('faqs');
    Route::get('/page/{slug}', [FrontController::class, 'page'])->name('custom_page');
    Route::get('/blog', [FrontController::class, 'blog'])->name('blog');
    Route::get('/post/{slug}', [FrontController::class, 'post'])->name('post');
    Route::get('/category/{slug}', [FrontController::class, 'category'])->name('category');
    Route::get('/tag/{name}', [FrontController::class, 'tag'])->name('tag');
    Route::get('/search', [FrontController::class, 'search'])->name('search');
    Route::get('/pricing', [FrontController::class, 'pricing_plans'])->name('pricing_plans');
    Route::get('/contact', [FrontController::class, 'contact'])->name('contact');
    Route::post('/contact/send-message', [FrontController::class, 'contact_send_message'])->name('contact_send_message');
    Route::get('/terms-of-use', [FrontController::class, 'terms'])->name('terms');
    Route::get('/privacy-policy', [FrontController::class, 'privacy'])->name('privacy');
    Route::post('/subscriber-submit', [FrontController::class, 'subscriber_submit'])->name('subscriber_submit');
    Route::get('/subscriber-verify/{email}/{token}', [FrontController::class, 'subscriber_verify'])->name('subscriber_verify');
    Route::post('/home-change', [FrontController::class, 'home_change'])->name('home_change');
});

Route::get('admin', function () {return redirect('admin/login');});

Route::middleware('admin')->prefix('admin')->group(function () {

    Session::put('locale', 'back');
    App::setLocale('back');

    Route::get('/dashboard',[AdminController::class,'dashboard'])->name('admin_dashboard');
    Route::get('/profile',[AdminController::class,'profile'])->name('admin_profile');
    Route::post('/profile',[AdminController::class,'profile_update'])->name('admin_profile_update');
    
    Route::get('/setting/general',[AdminSettingController::class,'general'])->name('admin_setting_general');
    Route::post('/setting/general/update',[AdminSettingController::class,'general_update'])->name('admin_setting_general_update');


    Route::get('/slider/index',[AdminSliderController::class,'index'])->name('admin_slider_index');
    Route::get('/slider/create',[AdminSliderController::class,'create'])->name('admin_slider_create');
    Route::post('/slider/store',[AdminSliderController::class,'store'])->name('admin_slider_store');
    Route::get('/slider/edit/{id}',[AdminSliderController::class,'edit'])->name('admin_slider_edit');
    Route::post('/slider/update/{id}',[AdminSliderController::class,'update'])->name('admin_slider_update');
    Route::get('/slider/destroy/{id}',[AdminSliderController::class,'destroy'])->name('admin_slider_destroy');


    Route::get('/service/index',[AdminServiceController::class,'index'])->name('admin_service_index');
    Route::get('/service/create',[AdminServiceController::class,'create'])->name('admin_service_create');
    Route::post('/service/store',[AdminServiceController::class,'store'])->name('admin_service_store');
    Route::get('/service/edit/{id}',[AdminServiceController::class,'edit'])->name('admin_service_edit');
    Route::post('/service/update/{id}',[AdminServiceController::class,'update'])->name('admin_service_update');
    Route::get('/service/destroy/{id}',[AdminServiceController::class,'destroy'])->name('admin_service_destroy');
    Route::get('/service/destroy-pdf/{id}',[AdminServiceController::class,'destroy_pdf'])->name('admin_service_destroy_pdf');
    Route::get('/service/faq/{id}',[AdminServiceController::class,'service_faq'])->name('admin_service_faq');
    Route::post('/service/faq/store/{service_id}',[AdminServiceController::class,'service_faq_store'])->name('admin_service_faq_store');
    Route::post('/service/faq/update/{faq_id}',[AdminServiceController::class,'service_faq_update'])->name('admin_service_faq_update');
    Route::get('/service/faq/destroy/{faq_id}',[AdminServiceController::class,'service_faq_destroy'])->name('admin_service_faq_destroy');


    Route::get('/portfolio/index',[AdminPortfolioController::class,'index'])->name('admin_portfolio_index');
    Route::get('/portfolio/create',[AdminPortfolioController::class,'create'])->name('admin_portfolio_create');
    Route::post('/portfolio/store',[AdminPortfolioController::class,'store'])->name('admin_portfolio_store');
    Route::get('/portfolio/edit/{id}',[AdminPortfolioController::class,'edit'])->name('admin_portfolio_edit');
    Route::post('/portfolio/update/{id}',[AdminPortfolioController::class,'update'])->name('admin_portfolio_update');
    Route::get('/portfolio/destroy/{id}',[AdminPortfolioController::class,'destroy'])->name('admin_portfolio_destroy');


    Route::get('/team-member/index',[AdminTeamMemberController::class,'index'])->name('admin_team_member_index');
    Route::get('/team-member/create',[AdminTeamMemberController::class,'create'])->name('admin_team_member_create');
    Route::post('/team-member/store',[AdminTeamMemberController::class,'store'])->name('admin_team_member_store');
    Route::get('/team-member/edit/{id}',[AdminTeamMemberController::class,'edit'])->name('admin_team_member_edit');
    Route::post('/team-member/update/{id}',[AdminTeamMemberController::class,'update'])->name('admin_team_member_update');
    Route::get('/team-member/destroy/{id}',[AdminTeamMemberController::class,'destroy'])->name('admin_team_member_destroy');
    Route::get('/team-member/experience/{id}',[AdminTeamMemberController::class,'experience'])->name('admin_team_member_experience');
    Route::post('/team-member/experience/store/{team_member_id}',[AdminTeamMemberController::class,'experience_store'])->name('admin_team_member_experience_store');
    Route::post('/team-member/experience/update/{experience_id}',[AdminTeamMemberController::class,'experience_update'])->name('admin_team_member_experience_update');
    Route::get('/team-member/experience/destroy/{experience_id}',[AdminTeamMemberController::class,'experience_destroy'])->name('admin_team_member_experience_destroy');

    Route::get('/testimonial/index',[AdminTestimonialController::class,'index'])->name('admin_testimonial_index');
    Route::get('/testimonial/create',[AdminTestimonialController::class,'create'])->name('admin_testimonial_create');
    Route::post('/testimonial/store',[AdminTestimonialController::class,'store'])->name('admin_testimonial_store');
    Route::get('/testimonial/edit/{id}',[AdminTestimonialController::class,'edit'])->name('admin_testimonial_edit');
    Route::post('/testimonial/update/{id}',[AdminTestimonialController::class,'update'])->name('admin_testimonial_update');
    Route::get('/testimonial/destroy/{id}',[AdminTestimonialController::class,'destroy'])->name('admin_testimonial_destroy');

    Route::get('/faq/index',[AdminFaqController::class,'index'])->name('admin_faq_index');
    Route::get('/faq/create',[AdminFaqController::class,'create'])->name('admin_faq_create');
    Route::post('/faq/store',[AdminFaqController::class,'store'])->name('admin_faq_store');
    Route::get('/faq/edit/{id}',[AdminFaqController::class,'edit'])->name('admin_faq_edit');
    Route::post('/faq/update/{id}',[AdminFaqController::class,'update'])->name('admin_faq_update');
    Route::get('/faq/destroy/{id}',[AdminFaqController::class,'destroy'])->name('admin_faq_destroy');


    Route::get('/post-category/index',[AdminPostCategoryController::class,'index'])->name('admin_post_category_index');
    Route::get('/post-category/create',[AdminPostCategoryController::class,'create'])->name('admin_post_category_create');
    Route::post('/post-category/store',[AdminPostCategoryController::class,'store'])->name('admin_post_category_store');
    Route::get('/post-category/edit/{id}',[AdminPostCategoryController::class,'edit'])->name('admin_post_category_edit');
    Route::post('/post-category/update/{id}',[AdminPostCategoryController::class,'update'])->name('admin_post_category_update');
    Route::get('/post-category/destroy/{id}',[AdminPostCategoryController::class,'destroy'])->name('admin_post_category_destroy');

    Route::get('/post/index',[AdminPostController::class,'index'])->name('admin_post_index');
    Route::get('/post/create',[AdminPostController::class,'create'])->name('admin_post_create');
    Route::post('/post/store',[AdminPostController::class,'store'])->name('admin_post_store');
    Route::get('/post/edit/{id}',[AdminPostController::class,'edit'])->name('admin_post_edit');
    Route::post('/post/update/{id}',[AdminPostController::class,'update'])->name('admin_post_update');
    Route::get('/post/destroy/{id}',[AdminPostController::class,'destroy'])->name('admin_post_destroy');


    Route::get('/pricing-plan/index',[AdminPricingPlanController::class,'index'])->name('admin_pricing_plan_index');
    Route::get('/pricing-plan/create',[AdminPricingPlanController::class,'create'])->name('admin_pricing_plan_create');
    Route::post('/pricing-plan/store',[AdminPricingPlanController::class,'store'])->name('admin_pricing_plan_store');
    Route::get('/pricing-plan/edit/{id}',[AdminPricingPlanController::class,'edit'])->name('admin_pricing_plan_edit');
    Route::post('/pricing-plan/update/{id}',[AdminPricingPlanController::class,'update'])->name('admin_pricing_plan_update');
    Route::get('/pricing-plan/destroy/{id}',[AdminPricingPlanController::class,'destroy'])->name('admin_pricing_plan_destroy');
    Route::get('/pricing-plan/option/{id}',[AdminPricingPlanController::class,'option'])->name('admin_pricing_plan_option');
    Route::post('/pricing-plan/option/store/{option_id}',[AdminPricingPlanController::class,'option_store'])->name('admin_pricing_plan_option_store');
    Route::post('/pricing-plan/option/update/{option_id}',[AdminPricingPlanController::class,'option_update'])->name('admin_pricing_plan_option_update');
    Route::get('/pricing-plan/option/destroy/{option_id}',[AdminPricingPlanController::class,'option_destroy'])->name('admin_pricing_plan_option_destroy');

    Route::get('/subscriber/index', [AdminSubscriberController::class, 'index'])->name('admin_subscriber_index');
    Route::get('/subscriber/send-message', [AdminSubscriberController::class, 'send_message'])->name('admin_subscriber_send_message');
    Route::post('/subscriber/send-message/submit', [AdminSubscriberController::class, 'send_message_submit'])->name('admin_subscriber_send_message_submit');
    Route::get('/subscriber/delete/{id}', [AdminSubscriberController::class, 'delete'])->name('admin_subscriber_delete');


    Route::get('/home-page/1/index',[AdminHomePageItemController::class,'home1'])->name('admin_home1_page_item_index');
    Route::post('/home-page/1/update',[AdminHomePageItemController::class,'home1_update'])->name('admin_home1_page_item_update');
    Route::get('/home-page/2/index',[AdminHomePageItemController::class,'home2'])->name('admin_home2_page_item_index');
    Route::post('/home-page/2/update',[AdminHomePageItemController::class,'home2_update'])->name('admin_home2_page_item_update');
    Route::get('/home-page/3/index',[AdminHomePageItemController::class,'home3'])->name('admin_home3_page_item_index');
    Route::post('/home-page/3/update',[AdminHomePageItemController::class,'home3_update'])->name('admin_home3_page_item_update');

    Route::get('/home-page/contact/photo/index',[AdminHomePageItemController::class,'contact_photo'])->name('admin_home_contact_photo_index');
    Route::post('/home-page/contact/photo/update',[AdminHomePageItemController::class,'contact_photo_update'])->name('admin_home_contact_photo_update');


    Route::get('/other-page/index',[AdminOtherPageItemController::class,'index'])->name('admin_other_page_item_index');
    Route::post('/other-page/about/update',[AdminOtherPageItemController::class,'about_update'])->name('admin_other_page_item_about_update');
    Route::post('/other-page/team-member/update',[AdminOtherPageItemController::class,'team_member_update'])->name('admin_other_page_item_team_member_update');
    Route::post('/other-page/team-member-single/update',[AdminOtherPageItemController::class,'team_member_single_update'])->name('admin_other_page_item_team_member_single_update');
    Route::post('/other-page/testimonial/update',[AdminOtherPageItemController::class,'testimonial_update'])->name('admin_other_page_item_testimonial_update');
    Route::post('/other-page/pricing/update',[AdminOtherPageItemController::class,'pricing_update'])->name('admin_other_page_item_pricing_update');
    Route::post('/other-page/faq/update',[AdminOtherPageItemController::class,'faq_update'])->name('admin_other_page_item_faq_update');
    Route::post('/other-page/services/update',[AdminOtherPageItemController::class,'services_update'])->name('admin_other_page_item_services_update');
    Route::post('/other-page/portfolios/update',[AdminOtherPageItemController::class,'portfolios_update'])->name('admin_other_page_item_portfolios_update');
    Route::post('/other-page/portfolio-single/update',[AdminOtherPageItemController::class,'portfolio_single_update'])->name('admin_other_page_item_portfolio_single_update');
    Route::post('/other-page/blog/update',[AdminOtherPageItemController::class,'blog_update'])->name('admin_other_page_item_blog_update');
    Route::post('/other-page/contact/update',[AdminOtherPageItemController::class,'contact_update'])->name('admin_other_page_item_contact_update');
    Route::post('/other-page/terms/update',[AdminOtherPageItemController::class,'terms_update'])->name('admin_other_page_item_terms_update');
    Route::post('/other-page/privacy/update',[AdminOtherPageItemController::class,'privacy_update'])->name('admin_other_page_item_privacy_update');
    Route::post('/other-page/search/update',[AdminOtherPageItemController::class,'search_update'])->name('admin_other_page_item_search_update');
    Route::post('/other-page/tag/update',[AdminOtherPageItemController::class,'tag_update'])->name('admin_other_page_item_tag_update');
    Route::post('/other-page/category/update',[AdminOtherPageItemController::class,'category_update'])->name('admin_other_page_item_category_update');

    Route::post('/other-page/custom/store',[AdminOtherPageItemController::class,'custom_page_store'])->name('admin_other_page_item_custom_page_store');
    Route::post('/other-page/custom/update/{id}',[AdminOtherPageItemController::class,'custom_page_update'])->name('admin_other_page_item_custom_page_update');
    Route::post('/other-page/custom/destroy/{id}',[AdminOtherPageItemController::class,'custom_page_destroy'])->name('admin_other_page_item_custom_page_destroy');
    

    Route::get('/menu/index',[AdminMenuController::class,'index'])->name('admin_menu_index');
    Route::post('/menu/update',[AdminMenuController::class,'update'])->name('admin_menu_update');

    Route::get('/client/index',[AdminClientController::class,'index'])->name('admin_client_index');
    Route::get('/client/create',[AdminClientController::class,'create'])->name('admin_client_create');
    Route::post('/client/store',[AdminClientController::class,'store'])->name('admin_client_store');
    Route::get('/client/edit/{id}',[AdminClientController::class,'edit'])->name('admin_client_edit');
    Route::post('/client/update/{id}',[AdminClientController::class,'update'])->name('admin_client_update');
    Route::get('/client/destroy/{id}',[AdminClientController::class,'destroy'])->name('admin_client_destroy');

    Route::get('/translation/front-end/index', [AdminTranslationController::class,'front_end'])->name('admin_translation_front_end');
    Route::post('/translation/front-end/update', [AdminTranslationController::class,'front_end_update'])->name('admin_translation_front_end_update');
    Route::post('/translation/front-end/translate', [AdminTranslationController::class,'front_end_translate'])->name('admin_translation_front_end_translate');
    Route::get('/translation/back-end/index', [AdminTranslationController::class,'back_end'])->name('admin_translation_back_end');
    Route::post('/translation/back-end/update', [AdminTranslationController::class,'back_end_update'])->name('admin_translation_back_end_update');
    Route::post('/translation/back-end/translate', [AdminTranslationController::class,'back_end_translate'])->name('admin_translation_back_end_translate');

});

Route::prefix('admin')->group(function () {

    Session::put('locale', 'back');
    App::setLocale('back');
    
    Route::get('/', function () {return redirect('/admin/login');});
    Route::get('/login',[AdminController::class,'login'])->name('admin_login');
    Route::post('/login',[AdminController::class,'login_submit'])->name('admin_login_submit');
    Route::get('/logout',[AdminController::class,'logout'])->name('admin_logout');
    Route::get('/forget-password',[AdminController::class,'forget_password'])->name('admin_forget_password');
    Route::post('/forget_password_submit',[AdminController::class,'forget_password_submit'])->name('admin_forget_password_submit');
    Route::get('/reset-password/{token}/{email}',[AdminController::class,'reset_password'])->name('admin_reset_password');
    Route::post('/reset-password/{token}/{email}',[AdminController::class,'reset_password_submit'])->name('admin_reset_password_submit');
});

Route::get('/back-blade-extract', [BackEndBladeExtractController::class, 'index']);
Route::get('/front-blade-extract', [FrontEndBladeExtractController::class, 'index']);