Пример #1
0
 public static function getWechatMenus($wid)
 {
     $menus = self::find()->where(['w_id' => $wid])->orderBy('id asc')->asArray()->all();
     // $menus = \yii\helpers\ArrayHelper::index($menus, 'id');
     $menus = \common\components\helpers\ArrayHelper::recursion($menus, 0, 1);
     return $menus;
 }
Пример #2
0
 public static function menusMap($merchant_id, $type = 1)
 {
     $menus = self::find()->where(['merchant_id' => $merchant_id])->orderBy('id asc')->asArray()->all();
     $menus = \common\components\helpers\ArrayHelper::recursion($menus, 0, 2);
     if ($type == 2) {
         return $menus;
     }
     $result = [];
     $result['0'] = '顶级';
     foreach ($menus as $v) {
         $result[$v['id']] = $v['html'] . $v['name'];
     }
     return $result;
 }