Reputation: 1295
Here, I am making all database fields as safe
for massive assignment?
[$this->attributes, 'safe', 'on' => self::SCENARIO_MIGRATION],
Is it correct and if not what is the best way to achieve this?
Upvotes: 1
Views: 1226
Reputation: 22174
Validation with safe
rule for all attributes does not validate anything, so it does not make much sense. Instead of creating such rules it may be better to skip validation directly in code:
$model->setAttributes($data, false);
$model->save(false);
But if you really need such "empty" validation rules, you should use attributes()
method to get list of attributes names:
[$this->attributes(), 'safe', 'on' => self::SCENARIO_MIGRATION],
Upvotes: 4