1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- namespace addons\unishop\controller;
- use app\common\controller\Api;
- use think\Db;
- class Category extends Api
- {
- protected $noNeedLogin = ['all','menu','inlist'];
- protected $noNeedRight = ['*'];
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \addons\unishop\model\Category();
- }
-
- public function all(){
- $all = $this->model
- ->where('type','product')
- ->where('status','normal')
- ->field('id,name,pid,image,type,flag,weigh')
- ->order('weigh ASC')
- ->select();
- if ($all) {
- $all = collection($all)->toArray();
- }
- $this->success('',$all);
- }
- public function inlist(){
- $list = Db::name('unishop_category')
- ->where('status','normal')
- ->field('id,name,image')
- ->order('weigh ASC')
- ->select();
- $list = list_domain_image($list,['image']);
- $this->success(1,$list);
- }
-
- public function menu()
- {
- $list = $this->model
- ->where('flag','index')
- ->where('status','normal')
- ->select();
- if ($list) {
- $list = collection($list)->toArray();
- }
- $this->success('菜单',$list);
- }
- }
|