find(); if ($exist) { throw new Exception("模型下存在栏目,无法进行删除"); } }); //删除模型后删除对应的表字段 self::afterDelete(function ($row) { Db::name("cms_fields")->where(['source' => 'model', 'source_id' => $row['id']])->delete(); }); } public function getFieldsAttr($value, $data) { return is_array($value) ? $value : ($value ? explode(',', $value) : []); } public function getSettingAttr($value, $data) { return is_array($value) ? $value : (array)json_decode($data['setting'], true); } public function setSettingAttr($value) { return is_array($value) ? json_encode($value) : $value; } }