/** * Finds the Messages model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Messages the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Messages::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionMessagesView() { $id = Yii::$app->request->get('id'); $messagesInfo = Messages::findOne($id); MessagesUsers::updateAll(['status' => 1], ['messages_id' => $id]); $levelName = Level::getOneLevelNameById(Yii::$app->user->identity->level_id); $photo = UsersInfo::getPhotoByUserId(\Yii::$app->user->id); $messageCount = MessagesUsers::getCountByUserIdAndType(\Yii::$app->user->id); $currentTrain = TrainUsers::getTrainByUserId(Yii::$app->user->id); $data = ['messagesInfo' => $messagesInfo, 'levelName' => $levelName, 'currentTrain' => $currentTrain, 'photo' => $photo, 'messageCount' => $messageCount]; return $this->render('messages-view', ['data' => $data]); }