'Initiating scraping...', 'response_body' => null, 'status' => 'processing', 'start_time' => now() ]); // Run the scraping services $service_google_sheet->run_service(); $service_pbg_task->run_service(); $service_tab_pbg_task->run_service(); // Update status to success $import_datasource->update([ 'status' => 'success', 'message' => 'Scraping completed successfully.', 'finish_time' => now() ]); } catch (\Exception $e) { Log::error('Scraping failed: ' . $e->getMessage(), ['trace' => $e->getTraceAsString()]); // Update status to failed if (isset($import_datasource)) { $import_datasource->update([ 'status' => 'failed', 'response_body' => 'Error: ' . $e->getMessage(), 'finish_time' => now() ]); } // Mark the job as failed $this->fail($e); } } }