24 lines
538 B
PHP
24 lines
538 B
PHP
<?php
|
|
|
|
namespace App\Traits;
|
|
|
|
use App\Models\Google2FA;
|
|
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
|
|
|
trait WithGoogle2FA
|
|
{
|
|
public static function bootWithGoogle2FA()
|
|
{
|
|
self::created(function ($model) {
|
|
$google2fa = app('pragmarx.google2fa');
|
|
$model->google2fa()->create([
|
|
'secret' => $google2fa->generateSecretKey(32),
|
|
]);
|
|
});
|
|
}
|
|
|
|
public function google2fa(): MorphOne
|
|
{
|
|
return $this->morphOne(Google2FA::class, 'subscriber');
|
|
}
|
|
} |