2017 © Pedro Peláez
 

library verifier

Email verification for Laravel 5

image

coderjp/verifier

Email verification for Laravel 5

  • Tuesday, September 13, 2016
  • by coderjp
  • Repository
  • 2 Watchers
  • 2 Stars
  • 669 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 7 Versions
  • 1 % Grown

The README.md

Verifier (Laravel 5 Package)

Verifier is a package for Laravel 5 that sends out verification emails to users in order for them to prove their email is valid. Users will click a link in the email to validate their address., (*1)

Installation

Require this package with composer using the following command:, (*2)

composer require coderjp/verifier

Then run composer install or composer update., (*3)

After updating composer, add the service provider to the providers array in config/app.php, (*4)

'Coderjp\Verifier\VerifierServiceProvider',

Generate the config file for changing various settings. This can be found in config/verifier.php., (*5)

php artisan vendor:publish --provider=Coderjp\\Verifier\\VerifierServiceProvider

Make sure the tables config option is correct. By default the table used is users. Then run the following command to generate the migrations:, (*6)

php artisan verifier:migration

Usage

Model

Add the VerifierUserTrait to the model you wish to verify against. This will usually be the User model., (*7)

<?php

use Coderjp\Verifier\Traits\VerifierUserTrait;

class User extends Model implements AuthenticatableContract, CanResetPasswordContract
{
    use Authenticatable, CanResetPassword, EntrustUserTrait, SoftDeletes, VerifierUserTrait;

    ...
}

Template

You will need to make a mail template for the welcome email to use. By default the config uses emails.welcome., (*8)

The variable $user will be passed to your template. This will be an array of the relevant user., (*9)


Hi {{ $user['name'] }}, Welcome to our site. Please click the following link to activate your account: {{ url('verify', $user['verification_code']) }} Regards, CoderJP

Verifying

Where you create a user, you can now call the sendVerification() method on the model. This will trigger an email to be sent to the user., (*10)

...

public function store(CreateUserRequest $request)
{
        $user = User::create($request->all());
        $user->sendVerification();

        ...
}

...

To verify a token you can use the verify() method like so:, (*11)

<?php

class UserController extends Controller {

    ...

    public function validate(Request $request, $code)
    {
            $user = User::verify($code);

            if ($user) {
                // $user = User model
                return view('user.validated');
            } else {
                // $user = null;
                return view('user.invalid');
            }
    }

    ...

}

If the code is valid, verify will set validated = true, remove the validation code from the database and return the related user. If the code is invalid null is returned., (*12)

Overriding

Some options may need more thought than a simple attribute, the following can be overwritten by declaring methods in your model, (*13)

To: Name

This is the name of the recipient. By default it uses the name attribute of the model, however you can override it by declaring the following:, (*14)

...

public function getVerificationEmailName() {
    return ucwords($this->first_name .' '. $this->last_name);
}

...

Email Subject

By default, the config option subject is used, however you can define the following method in the model:, (*15)

...

public function getVerificationEmailSubject()
{
    return 'Welcome to our site ' . $this->name;
}

...

License

Verifier is open-sourced software licensed under the MIT license, (*16)

The Versions

13/09 2016

dev-master

9999999-dev

Email verification for Laravel 5

  Sources   Download

MIT

The Requires

 

laravel email verification verify

13/09 2016

0.1.3

0.1.3.0

Email verification for Laravel 5

  Sources   Download

MIT

The Requires

 

laravel email verification verify

22/05 2015

0.1.2

0.1.2.0

Email verification for Laravel 5

  Sources   Download

MIT

The Requires

 

laravel email verification verify

20/05 2015

0.1.1

0.1.1.0

Email verification for Laravel 5

  Sources   Download

MIT

The Requires

 

laravel email verification verify

20/05 2015

dev-develop

dev-develop

Email verification for Laravel 5

  Sources   Download

MIT

The Requires

 

laravel email verification verify

20/05 2015

0.1.0

0.1.0.0

Email verification for Laravel 5

  Sources   Download

MIT

The Requires

 

laravel email verification verify

20/05 2015

0.0.1

0.0.1.0

Email verification for Laravel 5

  Sources   Download

MIT

The Requires

 

laravel email verification verify