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

72 lines
1.4 KiB
PHP

<?php
namespace Modules\User\Models;
use App\Models\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Support\Arr;
use Modules\User\Models\Traits\WechatAttribute;
use Modules\User\Traits\BelongsToUser;
class UserWechat extends Model
{
use BelongsToUser,
WechatAttribute;
const SEX = [
'0' => '未知',
'1' => '男',
'2' => '女',
];
/**
* Notes : 小程序关联
*
* @Date : 2021/6/10 3:40 下午
* @Author : Mr.wang
* @return HasOne
*/
public function mini(): HasOne
{
return $this->hasOne(UserWechatMini::class);
}
/**
* Notes : 公众号关联
*
* @Date : 2021/6/10 3:40 下午
* @Author : Mr.wang
* @return HasOne
*/
public function official(): HasOne
{
return $this->hasOne(UserWechatOfficial::class);
}
/**
* Notes : app关联
*
* @Date : 2021/6/10 3:40 下午
* @Author : Mr.wang
* @return HasOne
*/
public function app(): HasOne
{
return $this->hasOne(UserWechatApp::class);
}
/**
* Notes : 获取性别信息
*
* @Date : 2021/12/1 14:35
* @Author : Mr.wang
* @return string
*/
public function getSexAttribute(): string
{
return self::SEX[$this->sex] ?? '未知';
}
}