$products['data'][$k]['category_name'] = cache('categorys')[$v['category_id']]['name'];
}
return $products;
}
/**
* 获取产品详情
*/
function get_details($id){
$result = $this->get($id);
$product = $result->toArray();
$next = $this->where('id','<',$id)->where('category_id',$product['category_id'])->order('id desc')->find();
$prev = $this->where('id','>',$id)->where('category_id',$product['category_id'])->order('id asc')->find();
$prev = $prev?$prev->toArray():array('title'=>'返回列表','url'=>url('index/product/lists',['category_id'=>$product['category_id']]));
$next = $next?$next->toArray():array('title'=>'返回列表','url'=>url('index/product/lists',['category_id'=>$product['category_id']]));
$product['prev'] = array('title'=>$prev['title'],'url'=>$prev['url']);
$product['next'] = array('title'=>$next['title'],'url'=>$next['url']);
return $product;
}
}