使用雄辩的模型,您只需通过调用即可更新数据
$model->update( $data );
Run Code Online (Sandbox Code Playgroud)
但不幸的是,这并没有更新关系.
如果您还想更新关系,则需要手动分配每个值并调用push()然后:
$model->name = $data['name'];
$model->relationship->description = $data['relationship']['description'];
$model->push();
Run Code Online (Sandbox Code Playgroud)
通过这项工作,如果您要分配大量数据,它将变得一团糟.
我喜欢这样的事情
$model->push( $data ); // this should assign the data to the model like update() does but also for the relations of $model
Run Code Online (Sandbox Code Playgroud)
有人可以帮帮我吗?