<?php

use Illuminate\Support\Facades\Route;

use App\Http\Controllers\FormController;

use Illuminate\Foundation\Auth\EmailVerificationRequest;
use Illuminate\Http\Request;

use Illuminate\Support\Facades\Mail;

use App\Http\Controllers\ForgotPasswordController;

use App\Http\Controllers\Auth\ResetPasswordController;

use App\Http\Controllers\NewPasswordController;
use App\Http\Controllers\Auth\PasswordResetLinkController;



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

Route::middleware(['auth', 'verified'])->group(function () {
    // Rotas protegidas que exigem verificação de e-mail
    Route::get('/', function () {
        return view('Admin/index');
    });
    
    Route::get('formulario', function () {
        return view('email/formAdmin');
    })->name('formulario');
});

// Rota responsavel por enviar o formulario 
Route::post('enviar-formulario', [FormController::class, 'enviarEmail'])->name('enviar.formulario');

Route::get('/CreateUser', function(){
    return view('email/createUser');
});






//  Route::post('/reset-password', [ResetPasswordController::class, 'reset'])->name('password.update');
// Route::get('/forgot-password', [PasswordResetLinkController::class, 'create'])->middleware(['guest'])->name('password.request');



// Route::get('/email/verify/{id}/{hash}', function (EmailVerificationRequest $request) {
//     $request->fulfill();

//     return redirect('/');
// })->middleware(['auth', 'signed'])->name('verification.verify');


// Route::get('/email/verify', function () {
//     return view('auth.verify-email');
// })->middleware('auth')->name('verification.notice');

// Route::get('/email/verify/{id}/{hash}', function (EmailVerificationRequest $request) {
//     $request->fulfill();

//     return redirect('/');
// })->middleware(['auth', 'signed'])->name('verification.verify');

// Route::post('/email/verification-notification', function (Request $request) {
//     $request->user()->sendEmailVerificationNotification();

//     return back()->with('status', 'verification-link-sent');
// })->middleware(['auth', 'throttle:6,1'])->name('verification.send');



 Route::get('/test-email', function () {
     $to = 'vzx1red@gmail.com';
     $subject = 'Test Email from Laravel';

     $message = Mail::raw('This is a test email from Laravel.', function ($message) use ($to, $subject) {
         $message->to($to)->subject($subject);
     });

     if ($message) {
         return 'Email sent successfully';
     } else {
         return 'Failed to send email';
     }
 });


// Route::get('/forgot-password', [ForgotPasswordController::class, 'showLinkRequestForm'])->name('password.request');

// Route::post('/forgot-password', [ForgotPasswordController::class, 'sendResetLinkEmail'])->name('password.email');

// Route::get('/reset-password/{token}', [ResetPasswordController::class, 'showResetForm'])->name('password.reset');
// Route::post('/reset-password', [ResetPasswordController::class, 'reset'])->name('password.update')