<?php
use App\Http\Controllers\Backend\AdminAuthController;
use App\Http\Controllers\Backend\AuthController;
use App\Http\Controllers\Backend\BackendController;
use App\Http\Controllers\Backend\CategoryController;
use App\Http\Controllers\Backend\CityController;
use App\Http\Controllers\Backend\ContactController;
use App\Http\Controllers\Backend\CouponController;
//use App\Http\Controllers\Backend\LinkController;
use App\Http\Controllers\Backend\MediaController;
use App\Http\Controllers\Backend\PageController;
use App\Http\Controllers\Backend\BillingDeskController;
use App\Http\Controllers\Backend\ProductController;
use App\Http\Controllers\Backend\ReviewController;
use App\Http\Controllers\Backend\TagController;
use App\Http\Controllers\Backend\SupervisorController;
use App\Http\Controllers\Backend\CountryController;
use App\Http\Controllers\Backend\StateController;
use App\Http\Controllers\Backend\UserController;
use App\Http\Controllers\Backend\UserAddressController;
use App\Http\Controllers\Backend\ShippingCompanyController;
use App\Http\Controllers\Backend\PaymentMethodController;
use App\Http\Controllers\Backend\OrderController;
use App\Http\Controllers\Backend\SettingController;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;

Auth::routes(['verify' => true]);


Route::prefix("auth")->name("auth.")->group(function (){

    Route::post('logout', [AdminAuthController::class, 'logout'])
        ->middleware('auth:admin')
        ->name('logout');

    Route::middleware("guest:admin")->group( function () {
        Route::get('login', [AdminAuthController::class, 'login'])->name('login');
        Route::post('login/connexion', [AdminAuthController::class, 'connexion'])->name('login.connexion');
        Route::get('/forgot-password', [AdminAuthController::class, 'forgotPassword'])->name('forgot_password');
    });

});


Route::middleware("auth:admin")->group( function () {
    Route::get('/', [BackendController::class, 'index'])->name('index');
    Route::get('/account-settings', [AdminAuthController::class, 'accountSetting'])->name('account_setting');
    Route::patch('/account-settings', [AdminAuthController::class, 'updateAccount'])->name('account_setting.update');
    Route::get('/categories/{category}/remove-image', [CategoryController::class, 'removeImage'])->name('categories.remove_image');
    Route::resource('categories', CategoryController::class);
    Route::post('/products/remove-image', [ProductController::class, 'removeImage'])->name('products.remove_image');
    Route::resource('products', ProductController::class);
    Route::resource('tags', TagController::class);
    Route::resource('coupons', CouponController::class);
    Route::resource('reviews', ReviewController::class);
    Route::get('/supervisors/{supervisor}/remove-image', [SupervisorController::class, 'removeImage'])->name('supervisors.remove_image');
    Route::resource('supervisors', SupervisorController::class);
    Route::resource('countries', CountryController::class);
    Route::get('/states/get-states', [StateController::class, 'get_states'])->name('states.get_states');
    Route::resource('states', StateController::class);
    Route::get('/cities/get-cities', [CityController::class, 'get_cities'])->name('cities.get_cities');
    Route::resource('cities', CityController::class);
    Route::get('users/get-users', [UserController::class, 'get_users'])->name('users.get_users');
    Route::resource('users', UserController::class);
    Route::resource('user_addresses', UserAddressController::class);
    Route::resource('shipping_companies', ShippingCompanyController::class);
    Route::resource('payment_methods', PaymentMethodController::class);
    Route::resource('orders', OrderController::class)->except( 'edit');
    Route::resource('settings', SettingController::class)->only('index', 'update');
    Route::resource('contacts', ContactController::class)->except('create', 'edit', 'update');
   // Route::resource('links', LinkController::class)->except('show');
    Route::resource('pages', PageController::class);


    Route::post('settings/edit',[SettingController::class,"edit"])->name("settings.edit");


    Route::prefix("orders")->name("orders.")->group(function (){
        Route::put('set-status/{order?}',[OrderController::class,"setStatus"])->name("set-status");
        Route::get('{order?}',[OrderController::class,"show"])->name("show");
        Route::get('create/get-data-page',[OrderController::class,"getDataPage"])->name("get-data-page");
        Route::get('create/get-sales',[OrderController::class,"getSales"])->name("get-sales");
        Route::get('traitments/list',[OrderController::class,"listOrders"])->name("traitments.list");
        Route::get('traitments/show',[OrderController::class,"showOrder"])->name("traitments.show");
    });

    Route::prefix("billing-desks")->name("billing-desks.")->group(function (){
        Route::get("/",[BillingDeskController::class,"index"])->name("index");
        Route::post("dt-edit",[BillingDeskController::class,"dtEdit"])->name("dt-edit");

    });

    Route::prefix("medias")->name("medias.")->group(function (){
        Route::post("{media}/add-to-deletion",[MediaController::class,"addToDeletion"])->name("add-to-deletion");
    });

    Route::prefix("categories")->name("categories.")->group(function (){
        Route::get("/",[CategoryController::class,"index"])->name("index");
        Route::post("dt-edit",[CategoryController::class,"dtEdit"])->name("dt-edit");

    });

    require_once "roles.php";
    require_once "payments.php";
    require_once "customers.php";
    require_once "sales.php";

//    Route::name("admin.")->prefix("admin")->group(function (){
//        require_once  "payments-gateway.php";
//    });

});




