mirror of
https://github.com/elyby/accounts.git
synced 2026-04-25 16:52:45 +05:30
Реализована форма обратной связи
This commit is contained in:
39
api/controllers/FeedbackController.php
Normal file
39
api/controllers/FeedbackController.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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' => [
|
||||
'except' => ['index'],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function verbs() {
|
||||
return [
|
||||
'index' => ['POST'],
|
||||
];
|
||||
}
|
||||
|
||||
public function actionIndex() {
|
||||
$model = new FeedbackForm();
|
||||
$model->load(Yii::$app->request->post());
|
||||
if (!$model->sendMessage()) {
|
||||
return [
|
||||
'success' => false,
|
||||
'errors' => $this->normalizeModelErrors($model->getErrors()),
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user