value('value') ?? false; } public function UpdateConfig($name, $value) { return Setting::updateOrCreate( ['key' => $name], ['value' => $value] ); } public function trackDailyPriceExtreme(float $price): void { if ($price <= 0) { return; } $upSetting = Setting::where('key', 'up_price')->first(); $downSetting = Setting::where('key', 'down_price')->first(); if (!$upSetting || !$downSetting) { return; } $priceInt = (int) round($price); $today = now()->toDateString(); if (!$upSetting->updated_at || $upSetting->updated_at->toDateString() !== $today) { $this->UpdateConfig('up_price', $priceInt); $this->UpdateConfig('down_price', $priceInt); return; } $currentUp = (float) ($upSetting->value ?: 0); $currentDown = (float) ($downSetting->value ?: 0); if ($currentUp <= 0 || $priceInt > $currentUp) { $this->UpdateConfig('up_price', $priceInt); } if ($currentDown <= 0 || $priceInt < $currentDown) { $this->UpdateConfig('down_price', $priceInt); } } }