guild/frontend/modules/api/controllers/InterviewRequestController.php

33 lines
891 B
PHP
Raw Normal View History

2022-03-21 14:56:21 +03:00
<?php
namespace frontend\modules\api\controllers;
use common\models\InterviewRequest;
use common\services\InterviewRequestService;
use Yii;
use yii\base\InvalidConfigException;
use yii\web\ServerErrorHttpException;
class InterviewRequestController extends ApiController
{
public function verbs(): array
{
return [
'create-interview-request' => ['post']
];
}
/**
* @throws InvalidConfigException
* @throws ServerErrorHttpException
*/
public function actionCreateInterviewRequest(): InterviewRequest
{
$InterviewRequestModel = InterviewRequestService::createInterviewRequest(Yii::$app->getRequest()->getBodyParams());
if ($InterviewRequestModel->errors) {
throw new ServerErrorHttpException(json_encode($InterviewRequestModel->errors));
}
return $InterviewRequestModel;
}
}