<?php
namespace AppHttpControllers;
use IlluminateAuthEventsVerified;
use IlluminateHttpRedirectResponse;
use IlluminateHttpRequest;
use IlluminateRoutingController;
use AppModelsUser;
class VerifyEmailController extends Controller
{
public function __invoke(Request $request): RedirectResponse
{
$user = User::find($request->route('id'));
if ($user->hasVerifiedEmail()) {
return redirect(env('FRONT_URL') . '/email/verify/already-success');
}
if ($user->markEmailAsVerified()) {
event(new Verified($user));
}
return redirect(env('FRONT_URL') . '/email/verify/success');
}
}