<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\{
    QuestionController,
    EntrepriseController,
    ProprietaireController,
    ConjointController,
    BienController,
    InfoGeneraleController,
    MaisonController,
    AppartementController,
    AgricoleViticoleController,
    BienProprietaireController,
    ClientController,
    DemeureController,
    FondCommerceController,
    ForetController,
    ImmeubleController,
    LocalIndustrielController,
    TerrainController,
    LocalCommercialController,
    ParkingController,
    ImageController,
    LocationController,
    VenteController,
    MandatController,
    MailController,
};

/*
|--------------------------------------------------------------------------
| 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 () {
    return view('welcome');
});

Auth::routes();
Route::get('/logout', [App\Http\Controllers\Auth\LoginController::class, 'logout'])->name("logout");

Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');

// Client
Route::get('/contrat/{$bienId}', [ClientController::class, 'showContrat'])->name("client.contrat");

// Propriétaires
Route::group(['prefix' => 'creation-de-proprietaire'], function(){
    Route::get('/question/entreprise/', [QuestionController::class, 'entreprise'])->name("question.entreprise");
    Route::get('/entreprise', [EntrepriseController::class, 'create'])->name("entreprise.create");
    Route::post('/entreprise/store', [EntrepriseController::class, 'store'])->name("entreprise.store");
    Route::get('/create/{idEntreprise}', [ProprietaireController::class, 'createEntreprise'])->name("proprietaire-with-entreprise.create");
    Route::get('/create', [ProprietaireController::class, 'create'])->name("proprietaire.create");
    Route::post('/store', [ProprietaireController::class, 'store'])->name("proprietaire.store");
    Route::get('/{id}', [ProprietaireController::class, 'edit'])->name("proprietaire.edit");
    Route::post('/update/{id}', [ProprietaireController::class, 'update'])->name("proprietaire.update");
    Route::get('/question/conjoint/', [QuestionController::class, 'conjoint'])->name("questions.conjoint");
    Route::get('/conjoint/{idProprietaire}', [ConjointController::class, 'create'])->name("conjoint.create");
    Route::post('/conjoint/store', [ConjointController::class, 'store'])->name("conjoint.store");
    Route::get('/question/coproprietaire/', [QuestionController::class, 'coproprietaire'])->name("questions.coproprietaire");
    Route::get('/coproprietaire/{idProprietaire}', [ProprietaireController::class, 'coproprietaire'])->name("coproprietaire.create");
    Route::post('/coproprietaire/store', [ProprietaireController::class, 'coproprietaireStore'])->name("coproprietaire.store");
    Route::get('/enregistre', [ProprietaireController::class, 'enregistre'])->name("proprietaire.enregistre");
});

// Biens immobiliers
Route::group(['prefix' => 'creation-de-bien'], function() {
    // Bien
    Route::get('', [BienController::class, 'create'])->name('bien.create');
    Route::post('/store', [BienController::class, 'store'])->name('bien.store');
    Route::get('/{id}', [BienController::class, 'edit'])->name('bien.edit');
    Route::post('/update/{id}', [BienController::class, 'update'])->name('bien.update');
    // infos générales
    Route::get('/informations-generales/{bienId}', [InfoGeneraleController::class, 'create'])->name('infos-generales.create');
    Route::post('/informations-generales/store', [InfoGeneraleController::class, 'store'])->name('infos-generales.store');
    // Type du bien
    Route::get('/type-de-bien/{bienId}', [BienController::class, 'type'])->name('bien.type');
    Route::get('/type-de-bien/form/{bienId}', [BienController::class, 'typeForm'])->name('bien.type.form');
    Route::any('/type-de-bien/{bienId}/maison/store', [MaisonController::class, 'store'])->name('maison.store');
    Route::any('/type-de-bien/{bienId}/appartement/store', [AppartementController::class, 'store'])->name('appartement.store');
    Route::any('/type-de-bien/{bienId}/agricole-viticole/store', [AgricoleViticoleController::class, 'store'])->name('agricole.viticole.store');
    Route::any('/type-de-bien/{bienId}/demeure/store', [DemeureController::class, 'store'])->name('demeure.store');
    Route::any('/type-de-bien/{bienId}/immeuble/store', [ImmeubleController::class, 'store'])->name('immeuble.store');
    Route::any('/type-de-bien/{bienId}/terrain/store', [TerrainController::class, 'store'])->name('terrain.store');
    Route::any('/type-de-bien/{bienId}/local-commercial/store', [LocalCommercialController::class, 'store'])->name('local_commercial.store');
    Route::any('/type-de-bien/{bienId}/local-industriel/store', [LocalIndustrielController::class, 'store'])->name('local_industriel.store');
    Route::any('/type-de-bien/{bienId}/parking/store', [ParkingController::class, 'store'])->name('parking.store');
    Route::any('/type-de-bien/{bienId}/fond-commerce/store', [FondCommerceController::class, 'store'])->name('fond-commerce.store');
    Route::any('/type-de-bien/{bienId}/foret/store', [ForetController::class, 'store'])->name('foret.store');
    // Localisation et description du bien
    Route::get('/informations-flux/{bienId}', [BienController::class, 'fluxCreate'])->name('flux.create');
    Route::post('/informations-flux/{bienId}/store', [BienController::class, 'flux'])->name('flux.store');
    // Images du bien
    Route::get('/images/{bienId}/create', [ImageController::class, 'create'])->name('images.create');
    Route::post('/images/store', [ImageController::class, 'store'])->name('image.store');
    // Mandat vente / location
    Route::get('/question/vente-location/{bienId}', [QuestionController::class, 'vente_location'])->name("questions.vente-location");
    Route::get('/vente/{bienId}/create', [VenteController::class, 'create'])->name('vente.create');
    Route::get('/vente/{id}/edit', [VenteController::class, 'edit'])->name('vente.edit');
    Route::post('/vente/{id}/update', [VenteController::class, 'update'])->name('vente.update');
    Route::get('/location/{bienId}/create', [LocationController::class, 'create'])->name('location.create');
    Route::get('/location/{id}/edit', [LocationController::class, 'edit'])->name('location.edit');
    Route::post('/location/{id}/update', [LocationController::class, 'update'])->name('location.update');
    Route::any('/vente/store/{bienId}', [VenteController::class, 'store'])->name('vente.store');
    Route::post('/location/store/{bienId}', [LocationController::class, 'store'])->name('location.store');
        // Wysiwyg
        Route::get('/vente/{bienId}/mandat/create', [MandatController::class, 'venteCreate'])->name('vente.mandat.create');
        Route::get('/location/{bienId}/mandat/create', [MandatController::class, 'locationCreate'])->name('location.mandat.create');
        Route::post('/vente/mandat/store/{bienId}', [MandatController::class, 'venteStore'])->name('vente.mandat.store');
        Route::post('/location/mandat/store/{bienId}', [MandatController::class, 'locationStore'])->name('location.mandat.store');
        // Signature électronique
        Route::post('/{bienId}/mandat/vente/signature/store', [MandatController::class, 'signatureVente'])->name('signature.mandat.store');
        Route::post('/{bienId}/mandat/location/signature/store', [MandatController::class, 'signatureLocation'])->name('signature.location.mandat.store');
        Route::get('/{bienId}/mandat/location/signature/create', [MandatController::class, 'sigantureLocationStore'])->name('locations.mandats.signatures.create');
        Route::get('/{bienId}/mandat/vente/signature/create', [MandatController::class, 'sigantureVenteStore'])->name('ventes.mandats.signatures.create');
        Route::post('/{bienId}/mandat/vente/signature/mail/store', [MailController::class, 'vente'])->name('ventes.mandats.signatures.mail.store');
        Route::get('/{bienId}/mandat/location/signature/mail/store', [MailController::class, 'location'])->name('locations.mandats.signatures.mail.store');
        Route::post('/{bienId}/mandat/location/signature/mail/code/verification', [MailController::class, 'verificationLocation'])->name('locations.mandats.signatures.mail.code.verification');
        Route::post('/{bienId}/mandat/vente/signature/mail/code/verification', [MailController::class, 'verificationVente'])->name('ventes.mandats.signatures.mail.code.verification');
        // Ajouter proprietaires
        Route::post('/{bienId}/proprietaires/store', [BienProprietaireController::class, 'store'])->name('bien.proprietaire.store');
});
