2017 © Pedro Peláez
 

library laravel-tokens

php implementation of https://github.com/fnando/tokens.

image

forthelocal/laravel-tokens

php implementation of https://github.com/fnando/tokens.

  • Thursday, December 7, 2017
  • by 164c
  • Repository
  • 6 Watchers
  • 0 Stars
  • 393 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 3 % Grown

The README.md

Laravel Tokens

PHP implementation of https://github.com/fnando/tokens., (*1)

PHP from Packagist Packagist, (*2)

Build Status codecov, (*3)

Usage

Installation

composer require forthelocal/laravel-tokens
class User extends Model
{
    use Tokenizable;
}

// create a new user; remember that the token requires an existing record
// because it depends on its id
$user = User::create();

// create token that never expires
$user->addToken("activate");

// uses custom expires_at
user->addToken("valid", ["expires_at" => strtotime('1 day', time())]);

// uses the default size (48 characters)
$user->addToken("activate");

// uses custom size (up to 240)
$user->addToken("activate", ["length" => 120]);

// uses custom token value
$user->addToken("activate", ["token" => "abc123"]);

// create token with arbitrary data.
$user->addToken("activate", ["data" => [ "action" => "do something"]]);

// find token by name
$user->findTokenByName("reset_account");

// find valid token per user context.
$user->findValidToken("reset_account", "ea2f14aeac40");

// check if a token has expired
$user->tokens()->first()->isExpired();

// find user by token
User::findByToken("activate", "ea2f14aeac40");

// remove all expired tokens except those with NULL values
Token::clean();

// generate a token as string, without saving it
User::generateToken();

// remove a token by its name
$user->removeToken("activate");

// find user by valid token (same name, same hash, not expired)
User::findByValidToken("activate", "ea2f14aeac40");

// Token hash
echo $token; //=> ea2f14aeac40

License

MIT, (*4)

The Versions

07/12 2017

dev-master

9999999-dev

php implementation of https://github.com/fnando/tokens.

  Sources   Download

MIT

The Requires

 

The Development Requires

07/12 2017

v0.7.0

0.7.0.0

php implementation of https://github.com/fnando/tokens.

  Sources   Download

MIT

The Requires

 

The Development Requires

17/11 2017

v0.6.3

0.6.3.0

php implementation of https://github.com/fnando/tokens.

  Sources   Download

MIT

The Requires

 

The Development Requires

17/11 2017

v0.6.2

0.6.2.0

php implementation of https://github.com/fnando/tokens.

  Sources   Download

MIT

The Requires

 

The Development Requires

16/11 2017

v0.6.1

0.6.1.0

php implementation of https://github.com/fnando/tokens.

  Sources   Download

MIT

The Requires

 

The Development Requires

16/11 2017

v0.6.0

0.6.0.0

php implementation of https://github.com/fnando/tokens.

  Sources   Download

MIT

The Requires

 

The Development Requires

13/11 2017

v0.5.0

0.5.0.0

php implementation of https://github.com/fnando/tokens.

  Sources   Download

MIT

The Requires

 

The Development Requires