mirror of
https://github.com/yiisoft/yii2.git
synced 2025-12-19 07:07:58 +08:00
Fixes #11870: Fixed reliablity of example code in "Getting Data for Multiple Models"
This commit is contained in:
@@ -27,12 +27,16 @@ class UserController extends Controller
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$user = User::findOne($id);
|
||||
$profile = Profile::findOne($id);
|
||||
|
||||
if (!isset($user, $profile)) {
|
||||
if (!$user) {
|
||||
throw new NotFoundHttpException("The user was not found.");
|
||||
}
|
||||
|
||||
$profile = Profile::findOne($user->profile_id);
|
||||
|
||||
if (!$profile) {
|
||||
throw new NotFoundHttpException("The user has no profile.");
|
||||
}
|
||||
|
||||
$user->scenario = 'update';
|
||||
$profile->scenario = 'update';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user