lip 2 недель назад
Родитель
Сommit
ec6c916400
1 измененных файлов с 19 добавлено и 2 удалено
  1. 19 2
      app/Models/User.php

+ 19 - 2
app/Models/User.php

@@ -2,6 +2,9 @@
 
 namespace App\Models;
 
+// // 关键:导入正确的 Builder 类(Eloquent 构建器)
+// use Illuminate\Database\Eloquent\Builder;
+
 use Carbon\Carbon;
 
 /**
@@ -26,7 +29,21 @@ class User extends BaseModel
     ];
     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)) {
@@ -42,7 +59,7 @@ class User extends BaseModel
 
     public function wallet()
     {
-        return $this->belongsTo(Wallet::class, 'id', 'user_id')
+        return $this->belongsTo(Wallet::class, 'user_id', 'user_id')
             ->select('id', 'user_id', 'member_id', 'address', 'available_balance');
     }