/** * Inserts all the partially scraped titles from * performed tmdb api search query. * * @param array $titles * @return Collection */ public function insertFromTmdbSearch(array $titles) { $first = head($titles); $tempId = $first['temp_id']; if ($this->options->saveTmdbImages()) { $urls = array(); foreach ($titles as $k => $v) { if ($v['poster']) { $id = $v['tmdb_id'] . $v['type']; $titles[$k]['poster'] = "imdb/posters/{$id}.jpg"; $urls[$id] = $v['poster']; } } $this->images->saveMultiple($urls, null, 'imdb/posters/'); } $this->compileBatchInsert('titles', $titles)->save(); return Title::byTempId($tempId, 'tmdb_popularity'); }