shouldDisplay = $shouldDisplay; } public function title() { return '立即同步'; } public function confirm() { return '确定要立即同步JSON数据吗?'; } public function handle(Request $request) { try { $json =ItemJsonConfig::getData([],true); return $this->response()->success('同步成功')->refresh(); } catch (\Exception $e) { Log::error('Sync items.json exception: '.$e->getMessage()); return $this->response()->error('同步失败:'.$e->getMessage()); } } public function render() { if (!$this->shouldDisplay) { return ''; } return parent::render(); } public static function shouldDisplay(): bool { $json =ItemJsonConfig::getData(); $generatedAt = \Carbon\Carbon::createFromTimestamp($json['generated_ts']); $lastUpdated = \Carbon\Carbon::parse(\App\Module\GameItems\Models\Item::max('updated_at')); return $generatedAt->lt($lastUpdated); } }