public function __do($showtime_id)
 {
     if ($showtime_id = intval($showtime_id)) {
         $showtime = \models\entities\Showtime::manager()->getEntity($showtime_id);
         if ($showtime && $showtime->url) {
             $showtime->update(array('redirects' => new \DbTableFunction("redirects+1")), 'id');
             $this->_request->redirect($showtime->url);
         }
     }
     $this->_request->redirect('http://joseph.orilogbon.me');
 }
示例#2
0
 protected function initRelations()
 {
     $this->setOneToMany('nearbys', TheatreNearby::manager(), 'distance_m')->setOneToMany('showtimes', Showtime::manager(), 'show_date DESC, show_time ASC');
 }
 public function getShowtimes(GeocodeCached $locationInfo, $currentDate = null, $movie_id = null, $theatre_id = null, $dateOffset = 0)
 {
     if (!$this->loadData($locationInfo, $currentDate, false, $dateOffset)) {
         return [];
     }
     $currentDate = Utilities::dateFromOffset($currentDate, $dateOffset);
     $where = $locationInfo->getQueryWhere()->where('s.show_date', $currentDate);
     if ($theatre_id) {
         $where->where('s.theatre_id', $theatre_id);
     }
     if ($movie_id) {
         $where->where('s.movie_id', $movie_id);
     }
     $idsIn = Showtime::table()->selectFrom(['s.id'], 's')->innerJoin(['tn' => TheatreNearby::table()], "tn.theatre_id=s.theatre_id")->where($where)->generateSQL();
     //array('id', 'show_time', 'show_date', 'url');
     $showtimeWhere = (new \DbTableWhere())->whereInSql('id', $idsIn)->setOrderBy("theatre_id")->setOrderBy("movie_id")->setOrderBy("show_date")->setOrderBy("show_time")->setOrderBy("type");
     //showtimes
     $showtimes = Showtime::manager()->getEntitiesWhere($showtimeWhere);
     $showtimesResult = [];
     foreach ($showtimes as $showtime) {
         $key = "{$showtime->theatre_id}.{$showtime->movie_id}";
         if (!array_key_exists($key, $showtimesResult)) {
             $showtimesResult[$key] = [];
         }
         $showtimeArr = $showtime->toArray(0, 1, ['id', 'show_time', 'type']);
         $showtimeArr['link'] = strlen($showtime->url) > 0;
         if (ProxyMode::isCompact()) {
             $showtimesResult[$key][] = $this->compactShowtime($showtimeArr);
         } else {
             $showtimesResult[$key][] = $showtimeArr;
         }
     }
     return $showtimesResult;
 }