56 lines
1.0 KiB
PHP
56 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace Modules\User\Models\Traits;
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
use Modules\User\Models\UserWechat;
|
|
|
|
trait HasWechat
|
|
{
|
|
|
|
/**
|
|
* Notes : 用户微信信息
|
|
*
|
|
* @Date : 2021/5/26 11:14
|
|
* @Author : Mr.wang
|
|
* @return HasOne
|
|
*/
|
|
public function wechat(): HasOne
|
|
{
|
|
return $this->hasOne(UserWechat::class);
|
|
}
|
|
|
|
/**
|
|
* Notes: 是否关注公众号
|
|
*
|
|
* @Author: 玄尘
|
|
* @Date: 2022/8/3 16:23
|
|
*/
|
|
public function isOfficialSubscribe(): bool
|
|
{
|
|
return $this->wechat ? $this->wechat->isOfficialSubscribe() : false;
|
|
}
|
|
|
|
/**
|
|
* Notes: 获取openids
|
|
*
|
|
* @Author: 玄尘
|
|
* @Date: 2022/9/27 14:51
|
|
* @return string[]
|
|
*/
|
|
public function getOpenids()
|
|
{
|
|
if ($this->wechat) {
|
|
$data = $this->wechat->getOpenids();
|
|
} else {
|
|
$data = [
|
|
'mini' => '',
|
|
'official' => '',
|
|
];
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
|
|
} |