orderByDesc('id'); TableEngine::create($records, $request->all()) ->initSearch(['source', 'source_url']) ->select(['*']) ->export($records); return response()->json($records); } public function show($id) { $log = PriceSyncLog::with('items')->findOrFail($id); return response()->json($log); } public function runSync(ProductPriceSyncService $syncService, ConfigService $configService) { if (! $configService->isStore()) { return response()->json(['message' => 'فقط در حالت فروشگاه'], 422); } $syncService->syncStorePrices(true); $log = PriceSyncLog::with('items')->orderByDesc('id')->first(); return response()->json([ 'message' => $log ? 'قیمت‌ها به‌روزرسانی شد' : 'تغییری در قیمت محصولات نبود', 'data' => $log, ]); } }