Files
water_new/modules/User/Models/Traits/HasWechat.php
2023-03-08 09:16:04 +08:00

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