コード例 #1
0
 public function actionIndex()
 {
     $model = new ModelAduan();
     $session = Yii::$app->session;
     $username = $session->get('username');
     if ($username != null) {
         $member = $model->getAduan();
         return $this->render('index', ['data' => $member]);
     } else {
         return $this->redirect(Url::to(['login/index']));
     }
 }
コード例 #2
0
 public function actionGetaduan()
 {
     $model = new ModelAduan();
     $model_vote = new ModelVote();
     $data = $model->getAduan();
     header('Content-Type: application/json');
     if ($data == false) {
         echo json_encode(array('data' => $data, 'status' => '1'));
     } else {
         $arrs = array();
         foreach ($data as $key => $value) {
             $up_vote = $model_vote->getCountVote($value['id_aduan'], '1');
             $down_vote = $model_vote->getCountVote($value['id_aduan'], '2');
             $arrs[] = array('aduan' => $value, 'up_vote' => $up_vote['count_vote'], 'down_vote' => $up_vote['count_vote'], 'comments' => '');
         }
         echo json_encode(array('data' => $arrs, 'status' => '2'));
     }
     // URL : http://back.end/index.php?r=api/getaduan
 }