User.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. * @property $last_active_time 最后活跃时间
  16. */
  17. class User extends BaseModel
  18. {
  19. protected $table = 'users';
  20. protected $fillable = ['usdt', 'is_banned', 'last_active_time', 'visitor_id', 'register_ip', 'status', 'admin_note', 'member_id', 'first_name', 'game_id', 'username', 'secret_key', 'secret_pass', 'language'];
  21. protected $attributes = [
  22. 'language' => 'zh',
  23. ];
  24. protected $hidden = ['updated_at'];
  25. function getLastActiveTimeAttribute($value): string
  26. {
  27. if ($value > 0) {
  28. return date('Y-m-d H:i', strtotime($value));
  29. }
  30. return "";
  31. }
  32. function getCreatedAtAttribute($value): string
  33. {
  34. return Carbon::parse($value)->setTimezone('Asia/Shanghai')->format('Y-m-d');
  35. }
  36. public function wallet()
  37. {
  38. return $this->belongsTo(Wallet::class, 'id', 'user_id')
  39. ->select('id', 'user_id', 'member_id', 'address', 'available_balance');
  40. }
  41. public function setLanguage($language): void
  42. {
  43. $this->language = $language;
  44. }
  45. public function getMemberId()
  46. {
  47. return $this->member_id;
  48. }
  49. public function getUsername()
  50. {
  51. return $this->username;
  52. }
  53. public function getFirstName()
  54. {
  55. return $this->first_name;
  56. }
  57. }