<?php

use App\Http\Controllers\BatimentController;
use App\Http\Controllers\BatimentUniteController;
use App\Http\Controllers\ClientController;
use App\Http\Controllers\ContratController;
use App\Http\Controllers\ContratFreqPayController;
use App\Http\Controllers\DroitAccesController;
use App\Http\Controllers\FreqPayController;
use App\Http\Controllers\GestionStationController;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\InfraBatimentController;
use App\Http\Controllers\InfrastructureController;
use App\Http\Controllers\ManifestationInteretClientController;
use App\Http\Controllers\ManifestationInteretController;
use App\Http\Controllers\ManifestationTacheController;
use App\Http\Controllers\TacheController;
use App\Http\Controllers\TypeContratController;
use App\Http\Controllers\TypeTacheController;
use App\Http\Controllers\TypeUniteController;
use App\Http\Controllers\UniteController;
use App\Models\ContratFreqPay;
use App\Models\Infrastructure;
use App\Models\TypeTache;
use App\Models\TypeUnite;
use Illuminate\Support\Facades\Auth;

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

Route::get('/', function () {
    $Infra = Infrastructure::all();
    $TypeUnite = TypeUnite::all();
    return view('Impact/index',compact('Infra','TypeUnite'));
});
Route::resource('/ManifestationInteretClient', ManifestationInteretClientController::class);

Auth::routes();
// User Route
Route::middleware(['auth', 'user-role:user'])->group(function () {
    Route::get("/home", [HomeController::class, 'userHome'])->name('home');
});

// Editor Route
Route::middleware(['auth', 'user-role:editor'])->group(function () {
    Route::get("/editor/home", [HomeController::class, 'editorHome'])->name('home.editor');
});

// Admin Route
Route::middleware(['auth', 'user-role:admin'])->group(function () {
    Route::get("/admin/home", [HomeController::class, 'adminHome'])->name('home.admin');

    //BATIMENT

    Route::resource('/Batiments', BatimentController::class);
    Route::get('/Batiments/edit/{id}', [BatimentController::class, 'edit'])->name('gestionBatiments.edit');
    Route::put("/update+Batiments", [BatimentController::class, 'update'])->name('update-Batiments');
    Route::delete("/delete+Batiments", [BatimentController::class, 'destroy'])->name('delete-Batiments');

    //BATIMENT_UNITE

    Route::resource('/Batiments+Unites', BatimentUniteController::class);
    Route::get('/Batiments+Unites/edit/{id}', [BatimentUniteController::class, 'edit'])->name('gestionBatimentUnites.edit');
    Route::put("/update+Unites", [BatimentUniteController::class, 'update'])->name('update-BatimentUnites');
    Route::delete("/delete+Unites", [BatimentUniteController::class, 'destroy'])->name('delete-BatimentUnites');

    //CLIENT

    Route::resource('/Clients', ClientController::class);
    Route::get('/Clients/edit/{id}', [ClientController::class, 'edit'])->name('gestionClients.edit');
    Route::put("/update+Clients", [ClientController::class, 'update'])->name('update-Clients');
    Route::delete("/delete+Clients", [ClientController::class, 'destroy'])->name('delete-Clients');


    //CONTRAT

    Route::resource('/Contrats', ContratController::class);
    Route::get('/Contrats/edit/{id}', [ContratController::class, 'edit'])->name('gestionContrats.edit');
    Route::put("/update+Contrats", [ContratController::class, 'update'])->name('update-Contrats');
    Route::delete("/delete+Contrats", [ContratController::class, 'destroy'])->name('delete-Contrats');







    //CONTRAT_FREQPAY

    Route::resource('/Contrats+FreqPay', ContratFreqPayController::class);
    Route::get('/Contrats+FreqPay/edit/{id}', [ContratFreqPayController::class, 'edit'])->name('gestionContratsFreqPay.edit');
    Route::put("/update+Contrats+FreqPay", [ContratFreqPayController::class, 'update'])->name('update-ContratsFreqPay');
    Route::delete("/delete+Contrats+FreqPay", [ContratFreqPayController::class, 'destroy'])->name('delete-ContratsFreqPay');



    //FREQPAY

    Route::resource('/FreqPay', FreqPayController::class);
    Route::get('/FreqPay/edit/{id}', [FreqPayController::class, 'edit'])->name('gestionFreqPay.edit');
    Route::put("/update+FreqPay", [FreqPayController::class, 'update'])->name('update-FreqPay');
    Route::delete("/delete+FreqPay", [FreqPayController::class, 'destroy'])->name('delete-FreqPay');




    //INFRA_BATIMENT

    Route::resource('/Infra+Batiment', InfraBatimentController::class);
    Route::get('/Infra+Batiment/edit/{id}', [InfraBatimentController::class, 'edit'])->name('gestionInfraBatiment.edit');
    Route::put("/update+Infra+Batiment", [InfraBatimentController::class, 'update'])->name('update-InfraBatiment');
    Route::delete("/delete+Infra+Batiment", [InfraBatimentController::class, 'destroy'])->name('delete-InfraBatiment');




    //INFRASTRUCTURE

    Route::resource('/Infrastructure', InfrastructureController::class);
    Route::get('/Infrastructure/edit/{id}', [InfrastructureController::class, 'edit'])->name('gestionInfrastructure.edit');
    Route::put("/update+Infrastructure", [InfrastructureController::class, 'update'])->name('update-Infrastructure');
    Route::delete("/delete+Infrastructure", [InfrastructureController::class, 'destroy'])->name('delete-Infrastructure');


    //



    //TYPE_CONTRAT

    Route::resource('/Type+Contrat', TypeContratController::class);
    Route::get('/Type+Contrat/edit/{id}', [TypeContratController::class, 'edit'])->name('gestionTypeContrat.edit');
    Route::put("/update+Type+Contrat", [TypeContratController::class, 'update'])->name('update-TypeContrat');
    Route::delete("/delete+Type+Contrat", [TypeContratController::class, 'destroy'])->name('delete-TypeContrat');



    //TYPE_Unite

    Route::resource('/Type+Unite', TypeUniteController::class);
    Route::get('/Type+Unite/edit/{id}', [TypeUniteController::class, 'edit'])->name('gestionTypeUnite.edit');
    Route::put("/update+Type+Unite", [TypeUniteController::class, 'update'])->name('update-TypeUnite');
    Route::delete("/delete+Type+Unite", [TypeUniteController::class, 'destroy'])->name('delete-TypeUnite');



    //Unite

    Route::resource('/Unite', UniteController::class);
    Route::get('/Unite/edit/{id}', [UniteController::class, 'edit'])->name('gestionUnite.edit');
    Route::put("/update+Unite", [UniteController::class, 'update'])->name('update-Unite');
    Route::delete("/delete+Unite", [UniteController::class, 'destroy'])->name('delete-Unite');




    //Gestion utilisateur
    Route::resource('/Gestion+Utilisateurs', DroitAccesController::class);
    Route::GET('/Gestion+Utilisateurs/edit/{id}', [DroitAccesController::class, 'edit'])->name('gestionUtilisateurs.edit');
    Route::put("/update+Utilisateurs", [DroitAccesController::class, 'update'])->name('update-utilisateur');
    Route::delete("/delete+Utilisateurs", [DroitAccesController::class, 'destroy'])->name('delete-utilisateurs');




    //TypeTache

    Route::resource('/TypeTache', TypeTacheController::class);
    Route::get('/TypeTache/edit/{id}', [TypeTacheController::class, 'edit'])->name('gestionTypeTache.edit');
    Route::put("/update+TypeTache", [TypeTacheController::class, 'update'])->name('update-TypeTache');
    Route::delete("/delete+TypeTache", [TypeTacheController::class, 'destroy'])->name('delete-TypeTache');


    //Tache

    Route::resource('/Tache', TacheController::class);
    Route::get('/Tache/edit/{id}', [TacheController::class, 'edit'])->name('gestionTache.edit');
    Route::put("/update+Tache", [TacheController::class, 'update'])->name('update-Tache');
    Route::delete("/delete+Tache", [TacheController::class, 'destroy'])->name('delete-Tache');



    //ManifestationInteret

    Route::resource('/ManifestationInteret', ManifestationInteretController::class);
    Route::get('/ManifestationInteret/edit/{id}', [ManifestationInteretController::class, 'edit'])->name('gestionManifestationInteret.edit');
    Route::put("/update+ManifestationInteret", [ManifestationInteretController::class, 'update'])->name('update-ManifestationInteret');
    Route::delete("/delete+ManifestationInteret", [ManifestationInteretController::class, 'destroy'])->name('delete-ManifestationInteret');
});
