You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.2 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
  1. <?php
  2. namespace App\Http\Model;
  3. use App\Common\Token;
  4. class User extends BaseModel
  5. {
  6. //用户模型
  7. protected $table = 'user';
  8. public $timestamps = false;
  9. /**
  10. * 不能被批量赋值的属性
  11. *
  12. * @var array
  13. */
  14. protected $guarded = [];
  15. /**
  16. * 获取关联到用户的角色
  17. */
  18. public function userrole()
  19. {
  20. return $this->belongsTo(UserRole::class, 'role_id', 'id');
  21. }
  22. //签到
  23. public static function signin()
  24. {
  25. $user = self::where(['id'=>Token::$uid])->first();
  26. $signin_time='';
  27. if(!empty($user->signin_time)){$signin_time = date('Ymd',strtotime($user->signin_time));} //签到时间
  28. $today = date('Ymd',time()); //今日日期
  29. if($signin_time==$today){return '今日已签到!';}
  30. $signin_point = (int)Sysconfig::where(['varname'=>'CMS_SIGN_POINT'])->value('value'); //签到积分
  31. User::where(['id'=>Token::$uid])->update(['point'=>($user->point+$signin_point),'signin_time'=>date('Y-m-d H:i:s')]); //更新用户积分,及签到时间
  32. UserPoint::insert(['type'=>1,'point'=>$signin_point,'des'=>'签到','user_id'=>Token::$uid]); //添加签到积分记录
  33. return true;
  34. }
  35. }