PHP code example of voerro / laravel-email-verification

1. Go to this page and download the library: Download voerro/laravel-email-verification library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

voerro / laravel-email-verification example snippets


...
'providers' => [
    ...
    Voerro\Laravel\EmailVerification\EmailVerificationServiceProvider::class,
    ...
],
...



namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Voerro\Laravel\EmailVerification\Traits\EmailVerifiable;

class User extends Authenticatable
{
    use Notifiable, EmailVerifiable;

    ...
}

...
/**
 * The user has been registered.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  mixed  $user
 * @return mixed
 */
protected function registered($request, $user)
{
    return EmailVerification::registered($user);
}
...

...
/**
 * The application's route middleware groups.
 *
 * @var array
 */
protected $middlewareGroups = [
    ...
    'web' => [
        ...
        \Voerro\Laravel\EmailVerification\Middleware\LogoutUnverifiedUsers::class,
    ],
    ...
];

return EmailVerification::registeredApi($user);

...
/**
 * The application's route middleware groups.
 *
 * @var array
 */
protected $middlewareGroups = [
    ...
    'api' => [
        'throttle:60,1',
        'bindings',
        ...
        \Voerro\Laravel\EmailVerification\Middleware\LogoutUnverifiedUsers::class,
        ...
    ],
    ...
];

public static function registered($user)
{
    $token = self::generateToken($user->id);
    $token->sendVerificationEmail(UserRegistered::class);

    auth()->logout();

    return redirect(config('email_verification.redirect_on_failure'))
        ->with(
        'status',
        __('email-verification::email_verification.message.after.registration')
    );
}

public static function registeredApi($user)
{
    $token = self::generateToken($user->id);
    $token->sendVerificationEmail(UserRegistered::class);

    auth()->logout();

    return response()->json([
        'message' => __('email-verification::email_verification.message.after.registration'),
        'status' => 200
    ], 200);
}
bash
php artisan migrate