Laravel大规模任务

时间:2013-02-27 02:28:01

标签: php laravel

Yii提供了一种方便的方式来大规模分配模型。我在谷歌上搜索,无法找到有关Laravel大规模作业的任何信息。 那么,Laravel是否提供相同的功能?

2 个答案:

答案 0 :(得分:7)

是:http://laravel.com/docs/eloquent#mass-assignment

但请务必确保将您的属性列入白名单,否则您将面临严重的安全问题。

答案 1 :(得分:1)

我还没有试过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']

一样