| @@ 167-186 (lines=20) @@ | ||
| 164 | $modifiedKeyword->keyword_tags = collect(explode(',', $keyword['KeywordTags'])); |
|
| 165 | } |
|
| 166 | ||
| 167 | if (is_null($keyword['KeywordStats'])) { |
|
| 168 | $modifiedKeyword->keyword_stats = null; |
|
| 169 | } else { |
|
| 170 | $localTrends = collect($keyword['KeywordStats']['LocalSearchTrendsByMonth'])->map(function ($searchVolume, $month) { |
|
| 171 | return new StatLocalSearchTrend([ |
|
| 172 | 'month' => strtolower($month), |
|
| 173 | 'search_volume' => ($searchVolume == '-') ? null : $searchVolume, |
|
| 174 | ]); |
|
| 175 | }); |
|
| 176 | ||
| 177 | $modifiedKeyword->keyword_stats = new StatKeywordStats([ |
|
| 178 | 'advertiser_competition' => $keyword['KeywordStats']['AdvertiserCompetition'], |
|
| 179 | 'global_search_volume' => $keyword['KeywordStats']['GlobalSearchVolume'], |
|
| 180 | 'regional_search_volume' => $keyword['KeywordStats']['RegionalSearchVolume'], |
|
| 181 | 'cpc' => $keyword['KeywordStats']['CPC'], |
|
| 182 | 'local_search_trends_by_month' => $localTrends->values(), |
|
| 183 | ]); |
|
| 184 | } |
|
| 185 | ||
| 186 | if (is_null($keyword['KeywordRanking'])) { |
|
| 187 | $modifiedKeyword->keyword_ranking = null; |
|
| 188 | } else { |
|
| 189 | $modifiedKeyword->keyword_ranking = new StatKeywordRanking([ |
|
| @@ 209-226 (lines=18) @@ | ||
| 206 | $modifiedKeyword->keyword_tags = collect(explode(',', $keyword['KeywordTags'])); |
|
| 207 | } |
|
| 208 | ||
| 209 | if (is_null($keyword['KeywordStats'])) { |
|
| 210 | $modifiedKeyword->keyword_stats = null; |
|
| 211 | } else { |
|
| 212 | $localTrends = collect($keyword['KeywordStats']['LocalSearchTrendsByMonth'])->map(function ($searchVolume, $month) { |
|
| 213 | return new StatLocalSearchTrend([ |
|
| 214 | 'month' => strtolower($month), |
|
| 215 | 'search_volume' => ($searchVolume == '-') ? null : $searchVolume, |
|
| 216 | ]); |
|
| 217 | }); |
|
| 218 | ||
| 219 | $modifiedKeyword->keyword_stats = new StatKeywordStats([ |
|
| 220 | 'advertiser_competition' => $keyword['KeywordStats']['AdvertiserCompetition'], |
|
| 221 | 'global_search_volume' => $keyword['KeywordStats']['GlobalSearchVolume'], |
|
| 222 | 'targeted_search_volume' => $keyword['KeywordStats']['TargetedSearchVolume'], |
|
| 223 | 'cpc' => $keyword['KeywordStats']['CPC'], |
|
| 224 | 'local_search_trends_by_month' => $localTrends->values(), |
|
| 225 | ]); |
|
| 226 | } |
|
| 227 | ||
| 228 | $modifiedKeyword->created_at = $keyword['CreatedAt']; |
|
| 229 | ||