Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

VerifyEmailController in Api

<?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');
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #VerifyEmailController #Api
ADD COMMENT
Topic
Name
7+6 =