diff --git a/common/models/InterviewRequest.php b/common/models/InterviewRequest.php new file mode 100644 index 0000000..8608cb8 --- /dev/null +++ b/common/models/InterviewRequest.php @@ -0,0 +1,56 @@ + 255], + [['comment'], 'string'], + ]; + } + + /** + * {@inheritdoc} + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'email' => 'Email', + 'phone' => 'Phone', + 'profile_id' => 'Profile ID', + 'user_id' => 'User ID', + 'created_at' => 'Created At', + 'comment' => 'Комментарий', + ]; + } +} diff --git a/console/migrations/m210703_114553_create_interview_request_table.php b/console/migrations/m210703_114553_create_interview_request_table.php new file mode 100644 index 0000000..202ac42 --- /dev/null +++ b/console/migrations/m210703_114553_create_interview_request_table.php @@ -0,0 +1,33 @@ +createTable('{{%interview_request}}', [ + 'id' => $this->primaryKey(), + 'email' => $this->string(255)->notNull(), + 'phone' => $this->string(255), + 'profile_id' => $this->integer(11), + 'user_id' => $this->integer(11), + 'comment' => $this->text(), + 'created_at' => $this->integer(11), + ]); + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + $this->dropTable('{{%interview_request}}'); + } +} diff --git a/frontend/modules/api/controllers/ProfileController.php b/frontend/modules/api/controllers/ProfileController.php index b015bd3..04498df 100644 --- a/frontend/modules/api/controllers/ProfileController.php +++ b/frontend/modules/api/controllers/ProfileController.php @@ -4,6 +4,7 @@ namespace frontend\modules\api\controllers; use common\behaviors\GsCors; use common\classes\Debug; +use common\models\InterviewRequest; use frontend\modules\api\models\ProfileSearchForm; class ProfileController extends \yii\rest\Controller @@ -39,11 +40,25 @@ class ProfileController extends \yii\rest\Controller $searchModel = new ProfileSearchForm(); $searchModel->attributes = \Yii::$app->request->get(); - if ($id){ + if ($id) { return $searchModel->byId(); } return $searchModel->byParams(); } + public function actionAddToInterview() + { + if (\Yii::$app->request->isPost) { + $model = new InterviewRequest(); + $model->attributes = \Yii::$app->request->post(); + $model->created_at = time(); + if ($model->save()){ + return ['status' => 'success']; + } + + return ['status' => 'error']; + } + } + } diff --git a/frontend/modules/api/models/AddToInterviewForm.php b/frontend/modules/api/models/AddToInterviewForm.php new file mode 100644 index 0000000..7853802 --- /dev/null +++ b/frontend/modules/api/models/AddToInterviewForm.php @@ -0,0 +1,31 @@ +