belongsTo(UserRole::class, 'role_id', 'id'); } //签到 public static function signin() { $user = self::where(['id'=>Token::$uid])->first(); $signin_time=''; if(!empty($user->signin_time)){$signin_time = date('Ymd',strtotime($user->signin_time));} //签到时间 $today = date('Ymd',time()); //今日日期 if($signin_time==$today){return '今日已签到!';} $signin_point = (int)Sysconfig::where(['varname'=>'CMS_SIGN_POINT'])->value('value'); //签到积分 User::where(['id'=>Token::$uid])->update(['point'=>($user->point+$signin_point),'signin_time'=>date('Y-m-d H:i:s')]); //更新用户积分,及签到时间 UserPoint::insert(['type'=>1,'point'=>$signin_point,'des'=>'签到','user_id'=>Token::$uid]); //添加签到积分记录 return true; } }