Files
hyperf_service/app/Model/UserThird.php
2025-02-17 18:00:15 +08:00

58 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Model;
use App\Constants\Common\ThirdCode;
use Hyperf\Database\Model\Builder;
use Hyperf\DbConnection\Model\Model;
use Hyperf\Tappable\HigherOrderTapProxy;
/**
* @property int $id
* @property int $user_id
* @property string $open_id
* @property int $type
* @property string $union_id
*/
class UserThird extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'user_third';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
protected array $guarded = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['id' => 'integer', 'user_id' => 'integer', 'type' => 'integer'];
const CREATED_AT = null;
const UPDATED_AT = null;
/**
* @param string $openId
* @return Builder|\Hyperf\Database\Model\Model|null
*/
public function getThirdInfoByOpenId(string $openId): \Hyperf\Database\Model\Model|Builder|null
{
return $this->where('open_id', $openId)->first();
}
/**
* @param int $userId
* @return HigherOrderTapProxy|mixed|string
*/
public function getWxThirdInfoByUserId(int $userId)
{
return $this->where('user_id', $userId)->where('type',ThirdCode::WX_LOGIN)->value('open_id') ?? '';
}
}