Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 4 拉威尔质量更新_Laravel 4 - Fatal编程技术网

Laravel 4 拉威尔质量更新

Laravel 4 拉威尔质量更新,laravel-4,Laravel 4,昨天我问了一个关于即时加载和表单模型绑定的问题。 这不知何故是一个后续问题 现在我想更新数据库中的记录 $user = \User::findOrFail($id); $user->fill(\Input::all()); $user->push(); 但这只会保存用户本身的数据。不是关系 user=saved user->profile=未保存 在我的用户模型上,我有一个包含所有可填充列的可填充数组。在其他模型上,比如我刚刚编写的profile模型pro

昨天我问了一个关于即时加载和表单模型绑定的问题。

这不知何故是一个后续问题

现在我想更新数据库中的记录

    $user = \User::findOrFail($id);
    $user->fill(\Input::all());
    $user->push();
但这只会保存用户本身的数据。不是关系

user=saved

user->profile=未保存


在我的用户模型上,我有一个包含所有可填充列的可填充数组。在其他模型上,比如我刚刚编写的profile模型
protected$filleble=['*']

您没有使用您的用户模型检索配置文件。

$user = \User::with('profile')->findOrFail($id);
这将为您提供要更新的配置文件属性。

解决方案:

对关系调用fill(),而不仅仅是用户模型

$user->fill($input)
$user->profile->fill($input['profile'])

因此,在“$user=\user::findOrFail($id);”之后,当您“dd($user->profile)”时,是否有“null”以外的内容?您在哪里加载相对模型?