public function actionIndex()
 {
     /*
      * get Gym list
      * */
     $gymList = Gym::findAll(['status' => Gym::STATUS_ACTIVE]);
     return $this->render('index', ['modle' => $gymList]);
 }
 public function getGym()
 {
     return $this->hasOne(Gym::className(), ['id' => 'gym_id']);
 }
示例#3
0
 public function saveGymInfo($id)
 {
     $gym = new Gym();
     $gym->name = $this->name;
     // $gym->status = $this->status;
     $gym->contact = $this->contact;
     //$gym->logo = $this->logo;
     $gym->manager = $this->manager;
     $gym->description = $this->description;
     $gym->open_time = $this->open_time;
     $gym->location = $this->location;
     $gym->wechat = $this->wechat;
     $gym->support_membercard = $this->support_membercard;
     $gym->gym_admin_id = $id;
     $gym->created_at = time();
     $gym->updated_at = time();
     $gym->area_id = $this->province;
     $gym->latitude = 4.5;
     $gym->longitude = 4.7;
     if ($gym->save()) {
         $this->gym_id = $gym->id;
         $sports = $this->sports;
         foreach ($sports as $sport) {
             $gym_sports = new GymSports();
             $gym_sports->gym_id = $gym->id;
             $gym_sports->sports_id = $sport;
             echo 'before gymsports';
             echo $gym_sports->sports_id;
             echo 'end gm';
             $gym_sports->created_at = time();
             $gym_sports->updated_at = time();
             if ($gym_sports->save()) {
             } else {
                 return false;
             }
             next($sports);
         }
         return true;
     } else {
         echo 'fial';
         return false;
     }
 }
示例#4
0
 public function getGyms()
 {
     return $this->hasMany(Gym::className(), ['gym_admin_id' => 'id'])->where(['not', ['status' => Gym::STATUS_DELETED]])->orderBy('id');
 }