public static function getProfile() { if ($model = UserProfile::findOne(['user_id' => \Yii::$app->user->getId()])) { return $model; } else { $model = new UserProfile(); $model->user_id = \Yii::$app->user->getId(); return $model; } }
public function actionPosOwner($id) { $model = UserProfile::findOne(['user_id' => $id]); return $this->render('viewPosOwner', ['model' => $model]); }
/** * Deletes an existing UserProfile model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { $this->findModel($id)->delete(); if (($modelProfile = UserProfile::findOne(['user_id' => $id])) !== null) { $modelProfile->delete(); } return $this->redirect(['index']); }