这就是我现在正在做的:
protected $defaults = array( 'quantity' => 9,);public function __construct(array $attributes = array()){ $this->setRawAttributes($this->defaults, true); parent::__construct($attributes);}我将其建议为PR,因此我们无需在每个Model上都声明此构造函数,并且只需
$defaults在模型中声明数组即可轻松应用…
更新 :
正如cmfolio指出的那样, 实际的ANSWER非常简单 :
只需覆盖
$attributes属性!像这样:
protected $attributes = array( 'quantity' => 9,);
这里讨论了这个问题。



