Beispiel #1
0
 public function search()
 {
     $rs = MaggieLabel::find()->orderBy('id desc')->all();
     $map = array();
     foreach ($rs as $value) {
         $map[$value->id] = $value->attributes;
     }
     return $map;
 }
Beispiel #2
0
 public function actionList()
 {
     $labelMap = MaggieLabel::search();
     $rs = MaggieActive::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();
 }