PHP code example of rasulian / laravel-user-verification
1. Go to this page and download the library: Download rasulian/laravel-user-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/ */
rasulian / laravel-user-verification example snippets
/*
* Package Service Providers...
*/
Rasulian\UserVerification\VerificationServiceProvider::class,
/*
* Application Service Providers...
*/
App\Providers\RouteServiceProvider::class,
return [
'table_names' => [
'users' => 'users',
'user_verifications' => 'user_verifications'
],
/**
* number of hours that needs to pass before
* we generate a new token\code but only if user request it.
*/
'generate_after' => 24
];
namespace App\Http\Controllers\Auth;
use App\Mail\Welcome;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Mail;
use Rasulian\UserVerification\Facades\Verification;
class RegisterController extends Controller
{
//
// Code
//
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest', ['except' => 'verifyUser']);
}
//
// Code
//
/**
* The user has been registered.
*
* @param \Illuminate\Http\Request $request
* @param mixed $user
* @return mixed
*/
protected function registered(Request $request, $user)
{
$token = Verification::getVerificationToken($user);
$url = route('user.verify', $token);
Mail::to($user->email)->send(new Welcome($url));
return redirect('/home')->with('success', 'Registered. Verify your email!');
}
public function verifyUser($token)
{
$user = Verification::verifyUserByToken($token);
if (auth()->guest())
auth()->login($user);
return redirect('/home')->with('success', 'Your email verified successfully!');
}
}