12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- namespace app\common\model;
- use app\utils\CurlUtil;
- use think\Db;
- use think\Model;
- /**
- * 动态评论
- */
- class UserModel extends Model
- {
- // 表名
- protected $name = 'user';
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = false;
- // 定义时间戳字段名
- protected $createTime = false;
- protected $updateTime = false;
- protected $deleteTime = false;
- /**
- * 获取头像
- * @param string $value
- * @param array $data
- * @return string
- */
- public function getAvatarAttr($value, $data)
- {
- if (!$value) {
- //如果不需要启用首字母头像,请使用
- $value = CurlUtil::getHttp('/assets/img/avatar.png');
- // $value = letter_avatar($data['nickname']);
- }else{
- $value = cdnurl($value);
- }
- return $value;
- }
- public static function getInfoById($id)
- {
- $info = self::where('id', $id)->find();
- unset(
- $info['username'],
- $info['password'],
- $info['salt'],
- $info['successions'],
- $info['maxsuccessions'],
- $info['prevtime'],
- $info['loginip'],
- $info['loginfailure'],
- $info['joinip'],
- $info['jointime'],
- $info['updatetime'],
- );
- return $info;
- }
- public static function getInfoByUserNo($user_no)
- {
- $info = self::where('user_no', $user_no)->find();
- unset(
- $info['username'],
- $info['password'],
- $info['salt'],
- $info['successions'],
- $info['maxsuccessions'],
- $info['prevtime'],
- $info['loginip'],
- $info['loginfailure'],
- $info['joinip'],
- $info['jointime'],
- $info['updatetime'],
- );
- return $info;
- }
- public static function getInfoByChatId($chat_id)
- {
- $info = self::where('chat_id', $chat_id)->find();
- unset(
- $info['username'],
- $info['password'],
- $info['salt'],
- $info['successions'],
- $info['maxsuccessions'],
- $info['prevtime'],
- $info['loginip'],
- $info['loginfailure'],
- $info['joinip'],
- $info['jointime'],
- $info['updatetime'],
- );
- return $info;
- }
- }
|