Commit 5d99555bf8f8ada169641598e6722c3b8e93e3f5

Authored by Alexey Boroda
1 parent 92af5aa4

-Rest adding ready

Showing 1 changed file with 42 additions and 0 deletions   Show diff stats
frontend/controllers/FeedbackController.php 0 → 100644
  1 +<?php
  2 +
  3 + namespace frontend\controllers;
  4 +
  5 + use artbox\core\models\Feedback;
  6 + use yii\filters\Cors;
  7 + use yii\web\Controller;
  8 + use yii\web\Response;
  9 +
  10 + class FeedbackController extends Controller
  11 + {
  12 + public $enableCsrfValidation = false;
  13 +
  14 + public function behaviors()
  15 + {
  16 + return [
  17 + 'corsFilter' => [
  18 + 'class' => Cors::className(),
  19 + ],
  20 + ];
  21 + }
  22 +
  23 + public function actionIndex()
  24 + {
  25 + \Yii::$app->response->format = Response::FORMAT_JSON;
  26 +
  27 + if (\Yii::$app->request->isPost) {
  28 + $model = new Feedback(\Yii::$app->request->post());
  29 + if ($model->validate() && $model->save()) {
  30 + return [
  31 + 'status' => true,
  32 + 'message' => 'Success',
  33 + ];
  34 + }
  35 + }
  36 +
  37 + return [
  38 + 'status' => false,
  39 + 'message' => 'Error',
  40 + ];
  41 + }
  42 + }
0 \ No newline at end of file 43 \ No newline at end of file