1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- namespace app\ais\model;
- use think\Model;
- use category\Tree;
- class AisCity extends Model{
-
-
- public static function selectPath($parent_id) {
- $pathMaps[] = ['name'=>'城市','url'=>url('admin.city/index')];
- $getPath = self::getPath($parent_id);
- foreach ($getPath as $value) {
- $pathMaps[] = ['name' => $value['name'],'url' => url('admin.city/index',['parent_id'=>$value['id']])];
- }
- return $pathMaps;
- }
-
- public static function getPath($parent_id){
- $result = self::field('id,name,parent_id')->select();
- $tree = new Tree(array('id','parent_id','name','title'));
- return $tree->getPath($result,$parent_id);
- }
- }
|