<?php

use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Auth;

use App\Http\Controllers\Dashboard\HomeController;
use App\Http\Controllers\Dashboard\SettingController;
use App\Http\Controllers\Dashboard\SliderController;
use App\Http\Controllers\Dashboard\ServicesController;
use App\Http\Controllers\Dashboard\PartenersController;
use App\Http\Controllers\Dashboard\WhyChooseUsSectionsController;
use App\Http\Controllers\Dashboard\AboutUsSectionsController;
use App\Http\Controllers\Dashboard\TeamsController;
use App\Http\Controllers\AdminAuth\LoginController;


/*
|--------------------------------------------------------------------------
| Admin Routes
|--------------------------------------------------------------------------
|
| Here is where you can register admin routes for your application dashboard. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::middleware('auth:admin')->group(function () {
    Route::get('/', [HomeController::class, 'index'])->name('dashboard');
    Route::resource('/slider', SliderController::class);
    Route::resource('/services', ServicesController::class);
    Route::resource('/parteners', PartenersController::class);
    Route::resource('/why_choose_us_sections', WhyChooseUsSectionsController::class);
    Route::prefix('about-us')->as('about_us.')->group(function () {
        Route::resource('/sections', AboutUsSectionsController::class);
        Route::resource('/teams', TeamsController::class);
    });

    Route::middleware('is_superadmin')->prefix('setting')->as('setting.')->group(function () {
        Route::get('/update', [SettingController::class, 'edit'])->name('edit');
        Route::post('/update', [SettingController::class, 'update'])->name('update');
        Route::get('/update/home_sections', [SettingController::class, 'editHomeSections'])->name('edit_home_sections');
        Route::post('/update/home_sections', [SettingController::class, 'updateHomeSections'])->name('update_home_sections');
    });
});


//admins auth
Route::group(['as' => 'admin_auth.'], function () {
    Route::get('/login', [LoginController::class, 'showLoginForm'])->name('login_form');
    Route::post('/login', [LoginController::class, 'login'])->name('login'); 
    Route::post('/logout', [LoginController::class, 'logout'])->name('logout'); 
});
