优惠券小程序

WxUser.php 653B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. class WxUser extends Model
  6. {
  7. use HasFactory;
  8. protected $table = 'wx_user';
  9. public $timestamps = false;
  10. protected static $unguarded = true;
  11. const USER_LOGIN_RDS = 'yhq-smallapp::UserLogin_';
  12. /**
  13. * 创建用户
  14. * */
  15. public static function createUser($data)
  16. {
  17. $userModel = new self;
  18. $userModel->openid = $data['openid'];
  19. $userModel->union_id = $data['union_id'];
  20. $result = $userModel->save();
  21. return $result ? $userModel->id : false;
  22. }
  23. }