Yii提供了一种对模型进行大规模赋值的便捷方法。我在谷歌上搜索,找不到任何关于Laravel的大规模任务的信息。那么,Laravel是否提供了同样的功能呢?
发布于 2013-02-27 11:08:26
是:http://laravel.com/docs/eloquent#mass-assignment
但绝对要确保将您的属性列入白名单,否则您将面临严重的安全问题。
发布于 2013-02-27 10:43:31
我还没有尝试过laravel,但在github上快速浏览一下就会发现有一个函数:
/**
* Hydrate the model with an array of attributes.
*
* @param array $attributes
* @param bool $raw
* @return Model
*/
public function fill(array $attributes, $raw = false)我猜你可以这样做
$product->fill($_POST['Product']);
就像你在Yii中做$product->attributes = $_POST['Product']一样
https://stackoverflow.com/questions/15103138
复制相似问题