User.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace App\Models;
  3. use Carbon\Carbon;
  4. /**
  5. * @property int $id
  6. * @property string $member_id
  7. * @property string $username
  8. * @property string $first_name
  9. * @property string $language
  10. * @property string $register_ip
  11. * @property integer $status
  12. * @property string $visitor_id
  13. * @property string $phone 用户手机号
  14. * @property string $admin_note
  15. */
  16. class User extends BaseModel
  17. {
  18. protected $table = 'users';
  19. protected $fillable = ['usdt', 'is_banned', 'visitor_id', 'register_ip', 'status', 'admin_note', 'member_id', 'first_name', 'game_id', 'username', 'secret_key', 'secret_pass', 'language'];
  20. protected $attributes = [
  21. 'language' => 'zh',
  22. ];
  23. protected $hidden = ['updated_at'];
  24. function getCreatedAtAttribute($value): string
  25. {
  26. return Carbon::parse($value)->setTimezone('Asia/Shanghai')->format('Y-m-d');
  27. }
  28. public function wallet()
  29. {
  30. return $this->belongsTo(Wallet::class, 'id', 'user_id')
  31. ->select('id', 'user_id', 'member_id', 'address', 'available_balance');
  32. }
  33. public function setLanguage($language): void
  34. {
  35. $this->language = $language;
  36. }
  37. public function getMemberId()
  38. {
  39. return $this->member_id;
  40. }
  41. public function getUsername()
  42. {
  43. return $this->username;
  44. }
  45. public function getFirstName()
  46. {
  47. return $this->first_name;
  48. }
  49. }