<?php

use App\Events\MessageSent;
use App\Http\Controllers\AreaCodeController;
use App\Http\Controllers\AreaController;
use App\Http\Controllers\CampanController;
use App\Http\Controllers\CarreraController;
use App\Http\Controllers\ChatController;
use App\Http\Controllers\CodeController;
use App\Http\Controllers\ConceptoController;
use App\Http\Controllers\DurationController;
use App\Http\Controllers\HorarioController;
use App\Http\Controllers\MailController;
use App\Http\Controllers\MaterialController;
use App\Http\Controllers\MedioController;
use App\Http\Controllers\NivelController;
use App\Http\Controllers\NoteController;
use App\Http\Controllers\PagoController;
use App\Http\Controllers\PermissionController;
use App\Http\Controllers\PlanController;
use App\Http\Controllers\PlaneController;
use App\Http\Controllers\PlantelController;
use App\Http\Controllers\ProspectoController;
use App\Http\Controllers\RoleController;
use App\Http\Controllers\StripeController;
use App\Http\Controllers\StripeWebhookController;
use App\Http\Controllers\TurnoController;
use App\Http\Controllers\UnsubscribeController;
use App\Http\Controllers\UserController;
use Illuminate\Support\Facades\Route;
use Laravel\Jetstream\Http\Controllers\Livewire\UserProfileController;

Route::match(['GET','POST'],'/unsubscribe', [UnsubscribeController::class,'handle']);

Route::get('/',function(){return view('auth.login');});
Route::get('/prueba',function(){return view('prueba.index');});
Route::post('/stripe/webhook', [StripeWebhookController::class, 'handle']);

Route::middleware(['auth:sanctum',config('jetstream.auth_session'),'verified',
    ])->group(function () {

    Route::middleware(['auth'])->group(function () {

        Route::resource('/area',AreaController::class);
        Route::resource('/areacode',AreaCodeController::class);
        Route::get('/dashboard', function () {return view('dashboard');})->name('dashboard');
        Route::resource('/campan',CampanController::class);
        Route::resource('/carrera',CarreraController::class);
        Route::resource('/code',CodeController::class);
        Route::resource('/concepto',ConceptoController::class);
        Route::get('/chat/start/{user}',[ChatController::class, 'start']);
        Route::get('/chat/{conversation}',[ChatController::class, 'show']);
        Route::post('/chat/send',[ChatController::class,'send']);
        Route::resource('/duration',DurationController::class);
        Route::get('/horario', [HorarioController::class, 'index'])->name('horario.index');
        Route::get('/horario/create', [HorarioController::class, 'create'])->name('horario.create');
        Route::post('/horario', [HorarioController::class, 'store'])->name('horario.store');
        Route::get('/horario/{user}', [HorarioController::class, 'show'])->name('horario.show');
        Route::get('/horario/{user}/edit', [HorarioController::class, 'edit'])->name('horario.edit');
        Route::put('/horario/{user}', [HorarioController::class, 'update'])->name('horario.update');
        Route::delete('/horario/{user}', [HorarioController::class, 'destroy'])->name('horario.destroy');
        Route::resource('/material',MaterialController::class);
        Route::resource('/medio',MedioController::class);
        Route::resource('/nivel',NivelController::class);
        Route::resource('/note',NoteController::class);
        Route::resource('/pago',PagoController::class);
        Route::post('/pagar/{pago}', [StripeController::class, 'pagar'])->name('pagar');
        Route::get('/pagar/{status}', [StripeController::class, 'show'])->name('pagar.show');
        Route::get('/perfil', [UserProfileController::class, 'show'])->name('perfil');});
        Route::resource('/permission',PermissionController::class);
        Route::resource('/plan',PlanController::class);
        Route::resource('/plane',PlaneController::class);
        Route::resource('/plantel',PlantelController::class);
        Route::resource('/prospecto',ProspectoController::class);
        Route::get('/registros', [CodeController::class,'registros' ])->name('registros');
        Route::resource('/role',RoleController::class);
        Route::get('/test-chat', function () { broadcast(new MessageSent('Hola realtime 🚀')); return 'Mensaje enviado';});
        Route::resource('/turno',TurnoController::class);
        Route::resource('/user',UserController::class);
        Route::resource('/mail',MailController::class);
        Route::get('/mailme/{user}',[MailController::class,'mailme'])->name('mailme');

    });
