Files
water_new/app/Traits/WithGoogle2FA.php
2023-03-08 09:16:04 +08:00

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');
}
}