12345678910111213141516171819202122232425262728 |
- <?php
- namespace app\api\controller\store;
- use app\admin\model\system\SystemAdmin;
- use app\models\store\StoreCategory;
- use app\models\system\SystemStore;
- use app\models\user\User;
- use app\Request;
- class CategoryController
- {
- public function category(Request $request)
- {
- $model = StoreCategory::with('children')->where('is_show', 1)->order('sort desc,id desc')->where('pid', 0);
- $user = User::getUserInfo($request->uid());
- $store_user = 0;
- if ($user['admin_id']) {
- $admin = SystemAdmin::where('id', $user['admin_id'])->find();
- $store_user = SystemStore::where('id', $admin['store_id'] ?? 0)->value('see');
- }
- if (!$store_user) {
- $model = $model->where('only_store_user', 0);
- }
- $cateogry = $model->select();
- return app('json')->success($cateogry->hidden(['add_time', 'is_show', 'sort', 'children.sort', 'children.add_time', 'children.pid', 'children.is_show'])->toArray());
- }
- }
|