Conditions | 2 |
Paths | 1 |
Total Lines | 18 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | public function handle() |
||
23 | { |
||
24 | $httpClient = new Client(); |
||
25 | |||
26 | PageModel::query()->where('dry', true)->chunkById(50, function ($items, $count) use($httpClient){ |
||
27 | $this->info(($count*50).' Pages'); |
||
28 | $pages = $items->pluck('page_id')->toArray(); |
||
29 | $pagesApiUri = config('wiki.api_uri').$this->queryPages.implode('|', $pages); |
||
30 | $response = $httpClient->get($pagesApiUri); |
||
31 | $content = json_decode($response->getBody()->getContents(), true); |
||
32 | $wikiPages = $content['query']['pages']; |
||
33 | |||
34 | foreach($wikiPages as $page){ |
||
35 | $pageModel = PageModel::query()->where('page_id', $page['pageid'])->first(); |
||
36 | $pageModel->dry = false; |
||
37 | $pageModel->title = $page['title']; |
||
38 | $pageModel->last_sync = (new \DateTime()); |
||
39 | $pageModel->save(); |
||
40 | } |
||
46 |