1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- namespace backend\base;
- use Yii;
- use yii\web\Response;
- class ToJson
- {
- public static function JsonData($data,$count = 0)
- {
- Yii::$app->response->format=Response::FORMAT_JSON;
- $list['rows'] = !empty($data) ? $data : [] ;
- $list['total'] = $count;
- return $list;
- }
-
- public static function JsonCode($code,$msg = '',$data = null)
- {
- Yii::$app->response->format=Response::FORMAT_JSON;
- $list['code'] = $code;
- $list['msg'] = $msg;
- $list['data'] = $data;
- return $list;
- }
- }
|