PHP code example of fbpkg / laravel-creds
1. Go to this page and download the library: Download fbpkg/laravel-creds 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/ */
fbpkg / laravel-creds example snippets
'pattern' => [
'id' => env('CRED_OTP_SMS_PATTERN'),
'variable' => 'code',
],
use Fbpkg\Cred\Otp\Services\OtpService;
$otpService->send(
identifier: '9120000000',
type: 'login',
channel: 'sms',
);
$result = $otpService->verify(
identifier: '9120000000',
type: 'login',
channel: 'sms',
code: '123456',
);
[
'success' => true,
'status' => 'verified',
'attempts_left' => 5,
'waiting_time' => 0,
]
use Fbpkg\Cred\Password\Traits\HasPassword;
class User extends Authenticatable
{
use HasPassword;
}
$result = $user->setPassword('your-password');
[
'success' => true,
'status' => 'set',
]
[
'success' => false,
'status' => 'reused',
]
$user->checkPassword('your-password');
'password' => [
'history_limit' => 10,
'prevent_reuse' => 5,
],
'cleanup' => [
'enabled' => true,
'after' => '24h',
],
'expires_in' => '2m',
'resend_after' => '1m',
'blocked_for' => '10m',
bash
php artisan vendor:publish --tag=cred-config
text
config/cred.php
bash
php artisan vendor:publish --tag=cred-migrations
bash
php artisan migrate