Call to a member function allowField() on null 错误总结

Call to a member function allowField() on null 

在空对象上调用  allowField()  

没有该模型对象无法调用,需要创建相应的模型

错误版本:

if ($this->$model->allowField(true)->isUpdate($isUpdate)->save($data) !== false) {

修改版本:

判断没有该模型就创建

$model = $this->model;
if (empty($model)) {
$model = new CorpModel;
}
if ($model->allowField(true)->isUpdate($isUpdate)->save($data) !== false) {
posted @ 2019-03-28 10:04  文彬哦  阅读(925)  评论(0)    收藏  举报