12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- namespace app\common\model;
- use think\Model;
- class UserAuths extends Model
- {
- // 设置字段信息
- protected $schema = [
- 'id' => 'int',
- 'userid' => 'int',
- 'identitytype' => 'string',
- 'identifier' => 'string',
- 'password' => 'string',
- 'logintime' => 'int',
- 'loginip' => 'string'
- ];
-
- // 设置字段自动转换类型
- protected $type = [
- 'logintime' => 'timestamp:Y-m-d H:i:s'
- ];
-
- public function getIdentitytypeTextAttr($value,$data)
- {
- $identitytype = ['mobile'=>'手机号', 'email'=>'邮箱', 'qq'=>'QQ', 'weixin'=>'微信', 'weibo'=>'微博'];
- return $identitytype[$data['identitytype']];
- }
- // 相对关联User
- public function user()
- {
- return $this->hasOne(User::class, "id", "userid");
- }
-
- }
|