Fixes #11870: Fixed reliablity of example code in "Getting Data for Multiple Models"

This commit is contained in:
Alexander Makarov
2016-07-02 21:10:00 +03:00
parent 3b5634bf8b
commit 6baf8dba4d

View File

@@ -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';