/** * Uploads provided background and associates with user. * * @param array $input * @param string $id * @return void */ public function uploadBg(array $input, $id) { $user = User::find($id); $path = "avatars/bgs/{$id}.jpg"; $this->images->saveBg($input, $path); $user->background = $path; $user->save(); }
/** * Uploads provided cover photo and associates with tv network. * * @param $logo * @param $name * @return string */ public function uploadCp($logo, $name) { $path = "assets/uploads/tv-networks/cover-photos/" . time() . '-' . $name . '-cover-photo' . '.jpg'; $this->images->saveBg($logo, $path); return $path; }
/** * Gets titles actor is know for. * * @return array. */ public function getKnownFor() { if (!$this->knownFor) { //grab all the titles actor is know for $known = $this->crawler->filter('div#knownfor > div'); //extract id, title, poster for each one and make multidim array from it foreach ($known as $k => $v) { $crawler = new crawler($v); $imdbid = $this->id($crawler->filter('a')->extract('href')); $title = head($crawler->filter('a > img')->extract('title')); $poster = $this->image($crawler->filter('a > img')->extract('src'), $imdbid); $year = Helpers::extractYear(head($crawler->filter('a')->eq(1)->extract('_text'))); $this->knownFor[] = array('imdb_id' => $imdbid, 'title' => $title, 'poster' => $poster, 'year' => $year); } } $this->images->saveMultiple($this->imgUrls, null, 'imdb/posters/'); return $this->knownFor; }