Exemplo n.º 1
0
 public function search()
 {
     $rs = MaggieLabelSociety::find()->orderBy('id desc')->all();
     $map = array();
     foreach ($rs as $value) {
         $map[$value->id] = $value->attributes;
     }
     return $map;
 }
Exemplo n.º 2
0
 public function actionList()
 {
     $labelMap = MaggieLabelSociety::search();
     $rs = MaggieActiveSociety::search();
     $data = ['count' => $rs['count'], 'rows' => []];
     foreach ($rs['model'] as $value) {
         $attributes = $value->attributes;
         $label = explode(',', $attributes['label']);
         foreach ($label as $val) {
             if (!isset($labelMap[$val])) {
                 continue;
             }
             $key = $labelMap[$val]['index'];
             $attributes[$key] = true;
         }
         $data['rows'][] = $attributes;
     }
     echo json_encode($data);
     Yii::$app->end();
 }