问下大家model的static内的函数,想返回一个error参数给controller中的this->error调用该怎么做?

model中的是这样的
public static function deleteCategory($id)
{
$rs = self::get(['parent_id' => $id]);
//TODO 检测是否存在商品,分类下以后商品无法删除
if ($rs) {
//存在子ID,则不能删除
//$this->error = '该分类存在子ID,无法删除';
return false;
} else {
return self::destroy($id);
}

 
controller中的代码是这样的
if ($category = CategoryModel::deleteCategory($ids)) {
$this->success('删除成功', url('wasumarket/category/index'));
} else {
$this->error();
}
已邀请:

dolphinphp

赞同来自:

if ($category = CategoryModel::deleteCategory($ids)) {
$this->success('删除成功', url('wasumarket/category/index'));
} else {
$this->error($category->getError());
}

要回复问题请先登录注册