info("Fetching campaign details from Google Ads..."); $adsService = new GoogleAdsService(); $clients = Client::where('status', 'ENABLED')->where('customer_id', '4744166776')->get(); // $clients = Client::where('status', 'ENABLED')->get(); foreach ($clients as $client) { $campaigns = GoogleCampaign::where('client_id', $client->id)->get(); if ($campaigns->isEmpty()) { $this->info("No campaigns found for Client ID: {$client->customer_id}"); continue; } else { foreach ($campaigns as $campaign) { $assets = $adsService->listAssetsByCampaignId($client->customer_id, $campaign->campaign_id); if (! empty($assets)) { foreach ($assets as $asset) { // $this->info('Here:'.$asset['status']); GoogleAsset::updateOrCreate( [ 'google_campaign_id' => $campaign->id, 'asset_id' => $asset['id'], ], [ 'name' => $asset['name'], 'type' => $asset['type'], 'added_by' => $asset['added_by'], 'use_case' => $asset['use_case'], 'approval_status' => $asset['approval_status'], 'review_status' => $asset['review_status'], 'status' => $asset['status'], ] ); $this->info("Fetched Asset: {$asset['name']} (Type: {$asset['type']}) for Campaign: {$campaign->name}"); } } else { $this->info("No assets found for Client ID: {$client->customer_id}, Campaign Name: {$campaign->name}"); } } } } DB::commit(); } catch (\Exception $e) { DB::rollBack(); Log::error('Error getting campaign details: '.$e->getMessage(), [ 'trace' => $e->getTraceAsString(), ]); return 1; } } }