public function actionAddship() { $player = Player::model()->findByAttributes(array('email' => Yii::app()->user->id)); if (isset($_POST['Ship'])) { $ship = new Ship(); $ship->attributes = $_POST['Ship']; if ($ship->addship($player)) { $this->redirect($this->createUrl('player/myship')); } else { $this->render('shipBuy', array('model' => $ship, 'player' => $player)); } } $ship = Ship::model()->findByAttributes(array('id' => $player->id)); if ($ship != null) { $this->render('needSellship'); return; } $ship = new Ship(); $this->render('shipBuy', array('model' => $ship, 'player' => $player)); }