Ken 10 ساعت پیش
والد
کامیت
52561c5a40
2فایلهای تغییر یافته به همراه40 افزوده شده و 1 حذف شده
  1. 10 1
      app/Models/User.php
  2. 30 0
      database/migrations/2026_02_06_135125_update_users.php

+ 10 - 1
app/Models/User.php

@@ -15,17 +15,26 @@ use Carbon\Carbon;
  * @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', 'visitor_id', 'register_ip', 'status', 'admin_note', 'member_id', 'first_name', 'game_id', 'username', 'secret_key', 'secret_pass', 'language'];
+    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'];
     protected $attributes = [
         'language' => 'zh',
     ];
     protected $hidden = ['updated_at'];
 
 
+    function getLastActiveTimeAttribute($value): string
+    {
+        if ($value > 0) {
+            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');

+ 30 - 0
database/migrations/2026_02_06_135125_update_users.php

@@ -0,0 +1,30 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration {
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        //
+        Schema::table('users', function (Blueprint $table) {
+            $table->integer('last_active_time')->default(0)->comment('最后活跃时间');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        //
+    }
+};