<?php

use App\Models\Reservation;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\BackOffice\CarController;
use App\Http\Controllers\BackOffice\DashboardController;
use App\Http\Controllers\FrontOffice\FrontendController;
use App\Http\Controllers\FrontOffice\SearchCarController;
use App\Http\Controllers\BackOffice\ReservationController;
use App\Http\Controllers\BackOffice\Settings\RoleController;
use App\Http\Controllers\BackOffice\Settings\UserController;
use App\Http\Controllers\BackOffice\Settings\BrandController;
use App\Http\Controllers\BackOffice\Settings\ColorController;
use App\Http\Controllers\BackOffice\Profile\ProfileController;
use App\Http\Controllers\BackOffice\Settings\ModeleController;
use App\Http\Controllers\BackOffice\Settings\CartTypeController;
use App\Http\Controllers\BackOffice\Settings\FuelTypeController;
use App\Http\Controllers\BackOffice\Settings\ConductorController;
use App\Http\Controllers\BackOffice\Settings\DestinationController;
use App\Http\Controllers\BackOffice\Settings\DestinationTypeController;
use App\Http\Controllers\BackOffice\Settings\TransmissionTypeController;


/*
|--------------------------------------------------------------------------
| 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!
|
*/

// Redirect routes
// Route::get('/', function () {
//     // return redirect('dashboard');
//     return view('backoffice.auth.login');
// });


Route::get('/', [FrontendController::class, 'index'])->name('home');
Route::get('/vehicule/{carID}', [FrontendController::class, 'carDetails'])->name('car.details');
Route::post('/rechercher', [SearchCarController::class, 'searchCar'])->name('search.car');
Route::post('rent-car', [ReservationController::class, 'setData'])->name('reservation.customer');


//...
Route::middleware(['auth'])->group(function () {
    // ...
    Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
    // ...
    Route::get('/profile', [ProfileController::class, 'index'])->name('profile');



    //.... Joseph

    // Prefix Security Route group to the Settings
    Route::prefix('security')->group(function () {

        // Roles Routes
        // Route::controller(RoleController::class)->group(function () {
        //     Route::get('/role', 'index')->name('role');
        //     Route::post('roleForm', 'showForm');
        //     Route::post('roleSet', 'setData');
        //     Route::post('roleGet', 'getData');
        //     Route::post('roleDelete', 'deleteData');
        // });

        // Users Routes
        // Route::controller(UserController::class)->group(function () {
        //     Route::get('/user', 'index')->name('user');
        //     Route::post('userForm', 'showForm');
        //     Route::post('userSet', 'setData');
        //     Route::post('userGet', 'getData');
        //     Route::post('userDelete', 'deleteData');
        //     Route::post('userGetOptions ', 'getOptions');
        // });
    });

     // Reservation
     Route::get('/nouvelle/reservation', [ReservationController::class, 'index'])->name('reservation');
     Route::get('/listes/reservation', [ReservationController::class, 'list'])->name('reservation.list');
     Route::post('new-reservation', [ReservationController::class, 'setData'])->name('reservation.post');
     Route::post('reservationGet', [ReservationController::class, 'getData']);
    //  Route::post('reservationDelete', [ReservationController::class, 'deleteData']);


    Route::prefix('general')->group(function () {
        // Brand routes
        Route::get('/brand', [BrandController::class, 'index'])->name('brand');
        Route::post('brandForm', [BrandController::class, 'ShowForm']);
        Route::post('brandSet', [BrandController::class, 'setData']);
        Route::post('brandGet', [BrandController::class, 'getData']);
        Route::post('brandDelete', [BrandController::class, 'deleteData']);

        // Model routes
        Route::get('/modele', [ModeleController::class, 'index'])->name('model');
        Route::post('modeleForm', [ModeleController::class, 'ShowForm']);
        Route::post('modeleSet', [ModeleController::class, 'setData']);
        Route::post('modeleGet', [ModeleController::class, 'getData']);
        Route::post('modeleDelete', [ModeleController::class, 'deleteData']);

        // Destination type routes
        Route::get('/destination-type', [DestinationTypeController::class, 'index'])->name('destinationtype');
        Route::post('destinationTypeForm', [DestinationTypeController::class, 'ShowForm']);
        Route::post('destinationTypeSet', [DestinationTypeController::class, 'setData']);
        Route::post('destinationTypeGet', [DestinationTypeController::class, 'getData']);
        Route::post('destinationTypeDelete', [DestinationTypeController::class, 'deleteData']);

        // Destination routes
        Route::get('/destinations', [DestinationController::class, 'index'])->name('destination');
        Route::post('destinationForm', [DestinationController::class, 'ShowForm']);
        Route::post('destinationSet', [DestinationController::class, 'setData']);
        Route::post('destinationGet', [DestinationController::class, 'getData']);
        Route::post('destinationDelete', [DestinationController::class, 'deleteData']);

        // Conductor routes
        Route::get('/conductor', [ConductorController::class, 'index'])->name('conductor');
        Route::post('conductorForm', [ConductorController::class, 'ShowForm']);
        Route::post('conductorSet', [ConductorController::class, 'setData']);
        Route::post('conductorGet', [ConductorController::class, 'getData']);
        Route::post('conductorDelete', [ConductorController::class, 'deleteData']);


        // Cart type routes
        Route::get('/cart-type', [CartTypeController::class, 'index'])->name('cartype');
        Route::post('carTypeForm', [CartTypeController::class, 'ShowForm']);
        Route::post('carTypeSet', [CartTypeController::class, 'setData']);
        Route::post('carTypeGet', [CartTypeController::class, 'getData']);
        Route::post('carTypeDelete', [CartTypeController::class, 'deleteData']);

        // Color routes
        Route::get('/color', [ColorController::class, 'index'])->name('color');
        Route::post('colorForm', [ColorController::class, 'ShowForm']);
        Route::post('colorSet', [ColorController::class, 'setData']);
        Route::post('colorGet', [ColorController::class, 'getData']);
        Route::post('colorDelete', [ColorController::class, 'deleteData']);

        // Fuelype routes
        Route::get('/fuel-type', [FuelTypeController::class, 'index'])->name('fueltype');
        Route::post('fuelTypeForm', [FuelTypeController::class, 'ShowForm']);
        Route::post('fuelTypeSet', [FuelTypeController::class, 'setData']);
        Route::post('fuelTypeGet', [FuelTypeController::class, 'getData']);
        Route::post('fuelTypeDelete', [FuelTypeController::class, 'deleteData']);


        // Transmission type routes
        Route::get('/transmission-type', [TransmissionTypeController::class, 'index'])->name('transmissionintype');
        Route::post('transmissionTypeForm', [TransmissionTypeController::class, 'ShowForm']);
        Route::post('transmissionTypeSet', [TransmissionTypeController::class, 'setData']);
        Route::post('transmissionTypeGet', [TransmissionTypeController::class, 'getData']);
        Route::post('transmissionTypeDelete', [TransmissionTypeController::class, 'deleteData']);


        Route::get('car', [CarController::class, 'index'])
            ->name('car');
        Route::post('carGet', [CarController::class, 'get']);
        Route::post('carForm', [CarController::class, 'form']);
        Route::post('carSet', [CarController::class, 'set']);
        Route::post('carDelete', [CarController::class, 'destroy']);


       
    });
});



// Inclure les routes spécifiques au backend
// require __DIR__.'/joseph.php';
// require __DIR__.'/romaric.php';