/** * Updates options in db. * * @param array $options * @return void */ public function updateOptions(array $options) { foreach ($options as $k => $v) { $insert[$k] = $v; } $this->dbWriter->updateOptions($insert); }
/** * Adds given title to given list of user. * * @param array $input * @return void */ public function add(array $input) { if ($user = Sentry::getUser()) { $data = array('user_id' => $user->id, 'title_id' => $input['title_id'], $input['list_name'] => 1); } $this->dbWriter->compileInsert('users_titles', $data)->save(); //fire eloquent saved event so cache is flushed Event::fire('eloquent.saved: *', new Title()); }
/** * Handles new season creation from input. * * @param array $input * @return Season */ public function create(array $input) { $temp = str_random(10); $input['temp_id'] = $temp; $this->dbWriter->CompileInsert('seasons', $input)->save(); return $this->season->where('temp_id', $temp)->limit(1)->get(array('id'))->first(); }
/** * Associates actors with titles. * * @param string $temp tempId of titles to associate. * @return void */ private function associate($temp, $known = 0) { $insert = array(); $titles = $this->title->Where('temp_id', '=', $temp)->lists('id'); foreach ($titles as $k => $v) { $insert[] = array('actor_id' => $this->actorId, 'title_id' => $v, 'known_for' => $known); } $this->dbWriter->compileBatchInsert('actors_titles', $insert)->save(); }
/** * Upload and associate image to title. * * @param array $input * @return void */ public function uploadImage(array $input) { $title = $this->model->find($input['title-id']); $name = str_random(25); $insert = array('local' => asset('assets/images/' . $name . '.jpg'), 'title_id' => $input['title-id']); $this->images->saveTitleImage($input, $name); $this->dbWriter->compileInsert('images', $insert)->save(); Event::fire('Titles.Modified', array($input['title-id'])); }
/** * Attaches actor to title from given input. * * @param array $input * @return void */ private function attachActor(array $input) { //if we've got no actor id in input means we're //attaching a new actor to title so we need to //insert this actor into db first if (!isset($input['actor-id'])) { $actor = $this->insertActor($input['actor']); $input['actor-id'] = $actor->id; } $this->dbWriter->compileInsert('actors_titles', array('actor_id' => $input['actor-id'], 'title_id' => $input['title-id'], 'char_name' => $input['char']))->save(); }
/** * Associates actors with titles. * * @param string $temp tempId of titles to associate. * @return void */ private function associate($temp, $known = 0, $names = array()) { $insert = array(); $titles = $this->title->Where('temp_id', '=', $temp)->get(array('id', 'tmdb_id')); foreach ($titles as $k => $v) { if (isset($names[$v['tmdb_id']])) { $insert[] = array('actor_id' => $this->modelId, 'title_id' => $v['id'], 'known_for' => $known, 'char_name' => $names[$v['tmdb_id']]); } else { $insert[] = array('actor_id' => $this->modelId, 'title_id' => $v['id'], 'known_for' => $known); } } $this->dbWriter->compileBatchInsert('actors_titles', $insert)->save(); }
/** * Scrapes titles from imdb advanced search * * @param array $input * @return void */ public function imdbAdvanced(array $input) { ini_set('max_execution_time', 0); $url = $this->compileImdbAdvancedUrl($input); $amount = $input['howMuch']; $currentPage = 1; while ($currentPage <= $amount) { $html = $this->curl($url); //increment current page by 100 as thats how many //titles page containts $currentPage = $currentPage + 100; //change url so it starts at 100 more then previous scrape $url = preg_replace('/&start=[0-9]+/', "&start={$currentPage}", $url); $data = $this->imdbSearch->compileSearchResults($html); if (!$data) { return false; } $this->dbWriter->insertFromImdbSearch($data); } Event::Fire('Titles.Updated'); return $currentPage; }
/** * Handles new episode creation/updating. * * @param array $input * @return void */ public function create(array $input) { $this->dbWriter->CompileInsert('episodes', $input)->save(); Event::fire('Titles.Modified', array($input['title_id'])); }
/** * Handles new season creation from input. * * @param array $input * @return void */ public function create(array $input) { $this->dbWriter->CompileInsert('seasons', $input)->save(); }
/** * Saves scraped news to the database. * * @return void */ private function save() { $this->dbWriter->compileBatchInsert('news', $this->news)->save(); }
/** * Saves featured movies to db. * * @param string $html * @return void */ private function saveFeatured($html) { foreach ($html as $h) { $flags = array('featured' => 1, 'fully_scraped' => 1, 'temp_id' => str_random(15)); $writer = new Writer(new ImdbData($h), $flags); $writer->saveAll(); } }
/** * Saves reviews from user input. * * @param array $input * @return void */ public function save(array $input) { $input['source'] = trans('main.brand'); $this->dbWriter->compileInsert('reviews', $input)->save(); }
/** * Adds given title to given list of user. * * @param array $input * @return void */ public function add(array $input) { $data = array('user_id' => $input['user'], 'title_id' => $input['title'], $input['list'] => 1); $this->dbWriter->compileInsert('users_titles', $data)->save(); }