public function getUrlAttr($value,$data){
return $value = strpos($value,'http') === false?url($value):$value;
}
public function getList($where=[],$field='*'){
$menu = $this->where($where)->field($field)->order('order_id asc')->select()->toArray();
return $menu;
}
/**
* 有效的菜单缓存
*/
public function setCache(){
//获取有效的菜单
$menu = $this->getList(['status'=>1]);
echo serialize($menu);
exit;
//启动缓存
cache('admin_menu',$menu);
return $menu?$menu:[];
}
出现Serialization of 'Closure' is not allowed这个错误,如果我注释了getUrlAttr这个方法就不会有问题了,明明是用toArray()转成数组了,为什么还报错呢? 最佳答案
