BiFace_Server_Lite/controllers/ApiController.php
2020-03-27 16:42:19 +07:00

55 lines
1.3 KiB
PHP

<?php
namespace app\controllers;
use Yii;
use yii\web\Controller;
use yii\filters\VerbFilter;
/**
* CardController implements the CRUD actions for Card model.
*/
class ApiController extends Controller {
/**
* {@inheritdoc}
*/
public function behaviors() {
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
public function actionSaveLogs() {
if (Yii::$app->request->post()) {
$post = Yii::$app->request->bodyParams;
$model = new \app\models\FaceLogs();
$model->create($post);
Yii::$app->response->format = "json";
return ["stt" => true];
}
}
public function actionSyncUrl() {
if (Yii::$app->request->post()) {
$post = Yii::$app->request->bodyParams;
$sync = \app\models\SyncUrl::find()->one();
if ($sync) {
$sync->data = $post['url'];
$sync->save();
} else {
$model = new \app\models\SyncUrl();
$model->create($post);
}
Yii::$app->response->format = "json";
return ["stt" => true];
}
}
}