1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace app\ais\model;
- use think\Model;
- use category\Tree;
- class AisShopCate extends Model{
- protected $pk = 'id';
-
-
- public static function edit($param){
- $data['title'] = $param['title'];
- $data['content'] = $param['content'];
- $data['picture'] = $param['picture'];
- $data['types'] = $param['types'];
- $data['show_type'] = $param['show_type'];
- $data['update_time'] = time();
- if(empty($param['id'])){
- $data['create_time'] = time();
- $data['member_miniapp_id'] = $param['member_miniapp_id'];
- return self::insert($data);
- }else{
- return self::update($data,['id'=>(int)$param['id']]);
- }
- }
-
- public static function selectPath(int $miniapp_id,$parent_id) {
- $pathMaps[] = ['name'=>'根目录','url'=>url('ais/shopCate/index')];
- $getPath = self::getPath($miniapp_id,$parent_id);
- foreach ($getPath as $value) {
- $pathMaps[] = ['name' => $value['title'],'url' => url('ais/shopCate/index',['parent_id'=>$value['id']])];
- }
- return $pathMaps;
- }
-
- public static function getPath($miniapp_id,$parent_id){
- $result = self::field('id,title,parent_id')->where(['member_miniapp_id' => $miniapp_id])->select();
- $tree = new Tree(array('id','parent_id','title','name'));
- return $tree->getPath($result,$parent_id);
- }
- }
|