| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace App\Models;
- // // 关键:导入正确的 Builder 类(Eloquent 构建器)
- // use Illuminate\Database\Eloquent\Builder;
- use Carbon\Carbon;
- /**
- * @property int $id
- * @property string $member_id
- * @property string $username
- * @property string $first_name
- * @property string $language
- * @property string $register_ip
- * @property integer $status
- * @property string $visitor_id
- * @property string $phone 用户手机号
- * @property string $admin_note
- * @property $last_active_time 最后活跃时间
- */
- class User extends BaseModel
- {
- protected $table = 'users';
- 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','user_code', 'agent_member_id','level'];
- protected $attributes = [
- 'language' => 'zh',
- ];
- protected $hidden = ['updated_at'];
-
- // public function newQuery($excludeDeleted = true): Builder
- // {
- // // 1. 获取原生 Eloquent 查询构建器
- // $query = parent::newQuery($excludeDeleted);
-
- // // 2. 强制清空当前连接的表前缀(从根源阻止拼接)
- // $this->getConnection()->setTablePrefix('');
-
- // // 3. 强制指定查询的表名为 la_operation(覆盖所有拼接逻辑)
- // $query->from('bot_users');
-
- // return $query;
- // }
-
- function getLastActiveTimeAttribute($value): string
- {
- if ($value > 0 && !is_numeric($value)) {
- return date('Y-m-d H:i', strtotime($value));
- }
- return "";
- }
- function getCreatedAtAttribute($value): string
- {
- return Carbon::parse($value)->setTimezone('Asia/Shanghai')->format('Y-m-d');
- }
- public function wallet()
- {
- return $this->belongsTo(Wallet::class, 'user_id', 'user_id')
- ->select('id', 'user_id', 'member_id', 'address', 'available_balance');
- }
- public function setLanguage($language): void
- {
- $this->language = $language;
- }
- public function getMemberId()
- {
- return $this->member_id;
- }
- public function getUsername()
- {
- return $this->username;
- }
- public function getFirstName()
- {
- return $this->first_name;
- }
- }
|