PHP code example of it-devgroup / laravel-activation-code
1. Go to this page and download the library: Download it-devgroup/laravel-activation-code 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/ */
it-devgroup / laravel-activation-code example snippets
$app->configure('activation_code');
php artisan activation:code:publish --tag=config
php artisan activation:code:publish --tag=migration
php artisan migrate
\ItDevgroup\LaravelActivationCode\Providers\ActivationCodeServiceProvider::class,
'providers' => [
...
\ItDevgroup\LaravelActivationCode\Providers\ActivationCodeServiceProvider::class,
]
php artisan vendor:publish --provider="ItDevgroup\LaravelActivationCode\Providers\ActivationCodeServiceProvider" --tag=config
php artisan activation:code:publish --tag=migration
php artisan migrate
namespace App;
class CustomFile extends \ItDevgroup\LaravelActivationCode\Model\ActivationCode
{
}
namespace App;
class CustomFile extends \ItDevgroup\LaravelActivationCode\Model\ActivationCode
{
protected $table = 'YOUR_TABLE_NAME';
// other code
}
$model = $service->getByCode('12345', 'user_register');
$model = $service->getByCode('12345', 'user_register', false);
// 1 parameter - code
// 2 parameter - type code (context) (user activation, password recovery, confirm order or other)
// 3 parameter - (optional) use exception (true - use (default), false - not use)
// generate code
$model = $service->make('[email protected] ', 'user_register');
// get code
$model = $service->get('[email protected] ', '12345', 'user_register');
... you PHP code
// activate of code
$service->delete($model);
// custom configuration
$service
->setMode(\ItDevgroup\LaravelActivationCode\ActivationCodeServiceInterface::MODE_SMS)
->setGenerateCodeMode(\ItDevgroup\LaravelActivationCode\ActivationCodeServiceInterface::GENERATE_CODE_MODE_ALPHABET_LOWER)
->setCodeLength(7)
->setCodeTTL('20m')
->setMaxAttempt(3);
// create code
$model = $service->make('[email protected] ', 'user_register');
// get code
$service->setMaxAttempt(3);
$model = $service->get('[email protected] ', '12345', 'user_register');
... you PHP code
// activate of code
$service->delete($model);