fix all error

This commit is contained in:
2026-08-22 14:42:28 +03:30
parent 7d1f8958e5
commit 3ea21594a6
+10 -6
View File
@@ -5,6 +5,7 @@ namespace App\Services;
use App\Models\Product; use App\Models\Product;
use App\Models\Setting; use App\Models\Setting;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Http\Client\Response;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
@@ -796,7 +797,7 @@ class ZaarboxPriceService
$responses = Http::pool(function ($pool) use ($now) { $responses = Http::pool(function ($pool) use ($now) {
foreach (self::PERIODS as $key => $config) { foreach (self::PERIODS as $key => $config) {
$start = $now->copy()->subHours($config['hours']); $start = $now->copy()->subHours($config['hours']);
$pool->as($key)->withHeaders([ $pool->as($key)->withoutVerifying()->timeout(12)->withHeaders([
'Referer' => 'https://tablo.montest.ir/', 'Referer' => 'https://tablo.montest.ir/',
'User-Agent' => 'Mozilla/5.0', 'User-Agent' => 'Mozilla/5.0',
])->get($this->historyUrl($start, $now)); ])->get($this->historyUrl($start, $now));
@@ -809,11 +810,14 @@ class ZaarboxPriceService
$response = $responses[$key] ?? null; $response = $responses[$key] ?? null;
$start = $now->copy()->subHours($config['hours']); $start = $now->copy()->subHours($config['hours']);
if (!$response || !$response->successful()) { if (!$response instanceof Response || !$response->successful()) {
Log::warning('Zaarbox price history fetch failed', [ $logContext = ['period' => $key];
'period' => $key, if ($response instanceof Response) {
'status' => $response?->status(), $logContext['status'] = $response->status();
]); } elseif ($response instanceof \Throwable) {
$logContext['message'] = $response->getMessage();
}
Log::warning('Zaarbox price history fetch failed', $logContext);
$prices[$key] = []; $prices[$key] = [];
continue; continue;
} }