init
This commit is contained in:
54
Traits/WithGoogle2FA.php
Normal file
54
Traits/WithGoogle2FA.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Google2FA\Traits;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
||||
use Modules\Google2FA\Models\Google2FA;
|
||||
|
||||
trait WithGoogle2FA
|
||||
{
|
||||
public static function bootWithGoogle2FA()
|
||||
{
|
||||
self::created(function ($model) {
|
||||
$model->google2fa()->create();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes : 模型关联
|
||||
*
|
||||
* @Date : 2022/12/1 14:15
|
||||
* @Author : <Jason.C>
|
||||
* @return MorphOne
|
||||
*/
|
||||
public function google2fa(): MorphOne
|
||||
{
|
||||
return $this->morphOne(Google2FA::class, 'subscriber');
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes : 获取用户名
|
||||
*
|
||||
* @override
|
||||
* @Date : 2022/12/1 14:15
|
||||
* @Author : <Jason.C>
|
||||
* @return string
|
||||
*/
|
||||
public function getUsername(): string
|
||||
{
|
||||
return 'USER-NAME';
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes : 获取昵称
|
||||
*
|
||||
* @override
|
||||
* @Date : 2022/12/1 14:15
|
||||
* @Author : <Jason.C>
|
||||
* @return string
|
||||
*/
|
||||
public function getNickname(): string
|
||||
{
|
||||
return 'NICK-NAME';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user