12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- namespace app\common\model;
- use think\db\Query;
- use think\Model;
- /**
- * 会员模型
- * @method Query|self exists($data)
- * @property array custom
- */
- class UserInfo extends Model
- {
- public function user(){
- return $this->belongsTo(User::class)->removeOption('soft_delete');
- }
- public function setCustomAttr($value){
- if(!$value){
- $value=[];
- }
- return json_encode($value,JSON_UNESCAPED_UNICODE);
- }
- public function getCustomAttr($value){
- $data=json_decode($value,true);
- static $config;
- if(!$config){
- $config=config('site.userApprove')?:[];
- }
- $res=[];
- foreach ($config as $key=>$title){
- $res[]=[
- 'key'=>$key,
- 'title'=>$title,
- 'value'=>$data[$key]??'',
- ];
- }
- return $res;
- }
- }
|