attributes['datetime']); } public function lastActivity() { $timestamp = $this->attributes['last_activity_at'] ?? $this->attributes['datetime']; return date("Y-m-d H:i:s", (int) $timestamp); } public function User() { $user = User::where("id", $this->attributes['userid'])->first(); return $user == null ? null : $user; } public function authorName() { $user = $this->User(); if ($user == null) { return '用户已删除'; } return $user->is_admin == 1 ? '管理员' : $user->user_name; } public function authorIsAdmin() { $user = $this->User(); return $user != null && $user->is_admin == 1; } }