2016-06-16 02:24:13 +05:30
|
|
|
<?php
|
|
|
|
namespace api\controllers;
|
|
|
|
|
|
|
|
use api\models\FeedbackForm;
|
|
|
|
use Yii;
|
|
|
|
use yii\helpers\ArrayHelper;
|
|
|
|
|
|
|
|
class FeedbackController extends Controller {
|
|
|
|
|
|
|
|
public function behaviors() {
|
|
|
|
return ArrayHelper::merge(parent::behaviors(), [
|
|
|
|
'authenticator' => [
|
2017-04-04 17:29:23 +05:30
|
|
|
'optional' => ['index'],
|
2016-06-16 02:24:13 +05:30
|
|
|
],
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function verbs() {
|
|
|
|
return [
|
|
|
|
'index' => ['POST'],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function actionIndex() {
|
|
|
|
$model = new FeedbackForm();
|
|
|
|
$model->load(Yii::$app->request->post());
|
|
|
|
if (!$model->sendMessage()) {
|
|
|
|
return [
|
|
|
|
'success' => false,
|
2016-11-30 23:27:30 +05:30
|
|
|
'errors' => $model->getFirstErrors(),
|
2016-06-16 02:24:13 +05:30
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
return [
|
|
|
|
'success' => true,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|