<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\dashboard\AuthController;
use App\Http\Controllers\dashboard\AboutController;
use App\Http\Controllers\dashboard\DashboardContoller;
use App\Http\Controllers\dashboard\PartnersController;
use App\Http\Controllers\dashboard\ServicesController;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/


Route::get('lang/{lang}', function ($lang){
    app()->setLocale($lang);
    session()->put('locale',$lang);

    return  redirect()->back();
})->name('lang');
Route::post('/login_post', [AuthController::class, 'login_post'])->name('login_form');
Route::get('/login', [AuthController::class, 'login_show'])->name('login');

Route::get('/logout', [AuthController::class, 'logout'])->name('logout');



Route::group(['prefix' =>'admin', 'middleware'=>'auth:admin'],function(){

    Route::get('/dashboard', [DashboardContoller::class, 'index'])->name('dashboard');

    //about
    Route::get('/about', [AboutController::class, 'about_index'])->name('about');
    Route::post('/about_update', [AboutController::class, 'about_update'])->name('about_update');


    //Our Achievements
    Route::get('/achievements', [AboutController::class, 'achievements_index'])->name('achievements');
    Route::post('/achievements_update', [AboutController::class, 'achievements_update'])->name('achievements_update');
    
    
    //Our partners
    Route::get('/our_partners', [PartnersController::class, 'partners_index'])->name('partners');
    Route::get('/our_partners/{id}/delete', [PartnersController::class, 'delete_partners'])->name('delete_partners');
    
    Route::post('/add_partner', [PartnersController::class, 'add_partner'])->name('add_partner');
    
    // contacts us 
    Route::get('/countact_us', [PartnersController::class, 'Contuct_index'])->name('Contuct_index');
    Route::get('/countact_us/download_excel', [PartnersController::class, 'ContuctUsExport'])->name('Contuct_export');
    
    
    //Newsletter
    Route::get('/newsletter', [PartnersController::class, 'newslettert_index'])->name('Newsletter_index');
    Route::get('newsletter/export/', [PartnersController::class, 'Newsletterexport'])->name('Newsletter_export');


    // services 
    Route::get('/services/index', [ServicesController::class, 'services_index'])->name('services');
    Route::get('/services/create', [ServicesController::class, 'services_create'])->name('services.create');
    Route::get('/services/{id}/sub_services', [ServicesController::class, 'sub_services'])->name('services.sub_services');
    Route::get('/services/{id}/sub_services/delete', [ServicesController::class, 'sub_services_delete'])->name('services.sub_services_delete');
    Route::get('/services/sub_services/delete_image/{id}', [ServicesController::class, 'sub_services_delete_images'])->name('sub_services.image.delete');
    Route::get('/services/sub_services/delete_element/{id}', [ServicesController::class, 'sub_services_delete_element'])->name('sub_services.element.delete');
    Route::get('/services/delete/{id}', [ServicesController::class, 'services_delete'])->name('services.delete');

    Route::post('/services/store', [ServicesController::class, 'services_store'])->name('services.store');
    Route::post('/services/load_services', [ServicesController::class, 'services_edit'])->name('services.edit');
    Route::post('/services/update_services', [ServicesController::class, 'services_update'])->name('services.update');
    Route::post('/sub_services/{id}/store', [ServicesController::class, 'sub_services_store'])->name('Sub_services.store');
    Route::post('/services/sub_services/load_edit_item', [ServicesController::class, 'load_edit_item'])->name('services.sub_services.load_edit_item');
    Route::post('/services/sub_services/update', [ServicesController::class, 'sub_services_update'])->name('services.sub_services.update');
    Route::post('/services/sub_services/load_edit_images', [ServicesController::class, 'load_edit_images'])->name('services.sub_services.load_edit_images');
    Route::post('/services/sub_services/save_images', [ServicesController::class, 'sub_services_save_images'])->name('services.sub_services.save_images');
    Route::post('/services/sub_services/load_edit_elements', [ServicesController::class, 'load_edit_elements'])->name('services.sub_services.load_elements');
    Route::post('/services/sub_services/save_element', [ServicesController::class, 'save_element'])->name('services.sub_services.save_element');
});


