|
@@ -4,12 +4,26 @@ namespace app\api\controller\store;
|
|
|
|
|
|
|
|
use app\models\store\StoreCategory;
|
|
use app\models\store\StoreCategory;
|
|
|
use app\Request;
|
|
use app\Request;
|
|
|
|
|
+use think\facade\Config;
|
|
|
|
|
|
|
|
class CategoryController
|
|
class CategoryController
|
|
|
{
|
|
{
|
|
|
public function category(Request $request)
|
|
public function category(Request $request)
|
|
|
{
|
|
{
|
|
|
- $cateogry = StoreCategory::with('children')->where('is_show', 1)->order('sort desc,id desc')->where('pid', 0)->select();
|
|
|
|
|
- return app('json')->success($cateogry->hidden(['add_time', 'is_show', 'sort', 'children.sort', 'children.add_time', 'children.pid', 'children.is_show'])->toArray());
|
|
|
|
|
|
|
+ $category = StoreCategory::with('children')->where('is_show', 1)->order('sort desc,id desc')->where('pid', 0)->select();
|
|
|
|
|
+ $category = $category->hidden(['add_time', 'is_show', 'sort', 'children.sort', 'children.add_time', 'children.pid', 'children.is_show'])->toArray();
|
|
|
|
|
+ $mining_enabled = Config::get('activity.mining_enabled', false);
|
|
|
|
|
+ if ($mining_enabled && count($category) > 0) {
|
|
|
|
|
+ $mining_id = Config::get('activity.mining_cate_id');
|
|
|
|
|
+ $mining_name = Config::get('activity.mining_display_name');
|
|
|
|
|
+ $mining_pic = Config::get('activity.mining_display_pic');
|
|
|
|
|
+ $category[0]['children'] = $category[0]['children']??[];
|
|
|
|
|
+ $category[0]['children'][] = [
|
|
|
|
|
+ 'id'=>$mining_id,
|
|
|
|
|
+ 'cate_name' => $mining_name,
|
|
|
|
|
+ 'pic' => $mining_pic,
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+ return app('json')->success($category);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|