<?php

use App\Http\Controllers\ProfileController;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\ProjectController;
use App\Http\Controllers\FractionalController;
use App\Http\Controllers\FormTemplateController;
use App\Http\Controllers\PropertyController;
use App\Http\Controllers\ImageController;
use App\Http\Controllers\PropertyTypeController;
use App\Http\Controllers\PublicFractionalController;
use App\Http\Controllers\PublicPropertyController;
use App\Http\Controllers\QuoteController;
use App\Http\Controllers\LeadController;
use App\Models\Quote;


Route::get('/', function () {
    return view('welcome');
});

Route::get('/dashboard', function () {
    return view('dashboard');
})->middleware(['auth', 'verified'])->name('dashboard');

Route::get('/propiedad/{property}', [PublicPropertyController::class, 'show'])->name('properties.public');

Route::get('/fractional/{fractional}', [PublicFractionalController::class, 'show'])->name('fractionals.public');

Route::get('/cotizacion/{slug}', function ($slug) {
    $quote = Quote::where('slug', $slug)->firstOrFail();

    $meses = [
        'january' => 'Enero',
        'february' => 'Febrero',
        'march' => 'Marzo',
        'april' => 'Abril',
        'may' => 'Mayo',
        'june' => 'Junio',
        'july' => 'Julio',
        'august' => 'Agosto',
        'september' => 'Septiembre',
        'october' => 'Octubre',
        'november' => 'Noviembre',
        'december' => 'Diciembre',
    ];

    return view('quotes.public-show', compact('quote', 'meses'));
})->name('public.quotes.show');


Route::view('/contacto', 'contact')->name('contact');


Route::post('/quote', [QuoteController::class, 'store'])->name('quote.store');

Route::middleware('auth')->group(function () {
    Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
    Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
    Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
    Route::resource('/projects', ProjectController::class);
    Route::resource('/fractionals', FractionalController::class);
    Route::resource('/form-templates', FormTemplateController::class);
    Route::resource('/properties', PropertyController::class);
    Route::resource('/property-types', App\Http\Controllers\PropertyTypeController::class);
    Route::resource('/images', ImageController::class);
    Route::post('/properties/{property}/clone', [PropertyController::class, 'clone'])->name('properties.clone');
    Route::post('/property-types/{propertyType}/clone', [PropertyTypeController::class, 'clone'])->name('property-types.clone');
    Route::post('/fractionals/{fractional}/clone', [FractionalController::class, 'clone'])->name('fractionals.clone');
    Route::get('/quotes', [QuoteController::class, 'index'])->name('quotes.index');
    Route::get('/quotes/{quote}', [QuoteController::class, 'show'])->name('quotes.show');






});

require __DIR__.'/auth.php';
