%PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
| Server IP : 14.207.165.8 / Your IP : 216.73.216.26 Web Server : Apache/2.4.18 (Ubuntu) System : Linux 246 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : root ( 0) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,pcntl_exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/eoffice/frontend/controllers/ |
Upload File : |
<?php
namespace frontend\controllers;
use yii\rest\ActiveController;
use backend\modules\dispatchs\models\Dispatchs;
use yii\filters\ContentNegotiator;
use yii\web\Response;
class ApiController extends ActiveController {
public function behaviors() {
// return [
// [
// 'class' => ContentNegotiator::className(),
// 'only' => ['index', 'view'],
// 'formats' => [
// 'application/json' => Response::FORMAT_JSON,
// ],
// ],
// ];
$behaviors = parent::behaviors();
$behaviors['contentNegotiator'] = [
'class' => 'yii\filters\ContentNegotiator',
'formats' => [
'text/html' => Response::FORMAT_JSON,
'application/json' => Response::FORMAT_JSON,
'application/xml' => Response::FORMAT_XML,
],
];
$behaviors['corsFilter'] = [
'class' => \yii\filters\Cors::className(),
'cors' => [
'Origin' => ['*'],
'Access-Control-Request-Method' => ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'],
'Access-Control-Request-Headers' => ['*'],
'Access-Control-Allow-Credentials' => true,
'Access-Control-Max-Age' => 86400,
'Access-Control-Allow-Origin' => ['*', 'http://abc.localhost/*', 'http://localhost:8101/*']
],
];
return $behaviors;
}
public $modelClass = 'backend\modules\dispatchs\models\Dispatchs';
public $serializer = [
'class' => 'yii\rest\Serializer',
// 'collectionEnvelope' => 'results',
];
// public function actionGet() {
// \Yii::$app->response->format = \yii\web\Response:: FORMAT_JSON;
// $location = Dispatchs::find()->limit(10)->all();
// if (count($location) > 0) {
// return array('status' => true, 'data' => $location);
// } else {
// return array('status' => false, 'data' => 'No Location Found');
// }
// }
public function actionHome()
{
\Yii::$app->response->format = \yii\web\Response:: FORMAT_JSON;
$data = Dispatchs::find()->limit(10)->all();
if (count($data) > 0) {
return array('status' => true, 'data' => $data);
} else {
return array('status' => false, 'data' => 'No Data Found');
}
}
public function actionChanpalace()
{
\Yii::$app->response->format = \yii\web\Response:: FORMAT_JSON;
$data = \backend\modules\chanpalace\models\Chanpalace::find()->limit(10)->all();
if (count($data) > 0) {
return array('status' => true, 'data' => $data);
} else {
return array('status' => false, 'data' => 'No Data Found');
}
}
public function actionTest($assetid)
{
\Yii::$app->response->format = \yii\web\Response:: FORMAT_JSON;
// $data = \backend\modules\chanpalace\models\Chanpalace::find()->where(['tel' => $tel])->limit(10)->all();
$data = \backend\modules\assetdata\models\AssetData::find()->where(['asset_id' => $assetid])->one();
if (count($data) > 0) {
return array('status' => true, 'data' => $data);
// return $data;
} else {
// return array('status' => false, 'data' => 'No Data Found');
return array('status' => false);
}
}
}