Example #1
0
 public function callback()
 {
     if (!$this->id) {
         throw new Exception('Movie does not exists yet');
     }
     if ($this->callback_at) {
         throw new Exception('Movie callback already executed');
     }
     $arr_infos = Callback::decode(Callback::getMovieInfo($this->tmdb_id));
     $arr_infos = array_shift($arr_infos);
     $this->addMovieImages(array_merge($arr_infos['posters'], $arr_infos['backdrops']));
     unset($arr_infos['posters']);
     unset($arr_infos['backdrops']);
     $this->addMovieAttributes($arr_infos);
     $this->callback_at = time();
     $this->save();
     $this->getRelated('attributes', true);
     $this->getRelated('images', true);
 }