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

70 lines
2.0 KiB
PHP
Raw Normal View History

2021-06-25 18:11:30 +03:00
<?php
namespace frontend\modules\api\controllers;
use common\behaviors\GsCors;
use common\classes\Debug;
2021-07-03 15:15:54 +03:00
use common\models\InterviewRequest;
2021-06-25 18:11:30 +03:00
use frontend\modules\api\models\ProfileSearchForm;
2021-08-05 14:08:00 +03:00
use yii\filters\auth\QueryParamAuth;
2021-06-25 18:11:30 +03:00
class ProfileController extends \yii\rest\Controller
{
public function behaviors()
{
return [
[
'class' => \yii\filters\ContentNegotiator::className(),
'formats' => [
'application/json' => \yii\web\Response::FORMAT_JSON,
],
],
2021-08-05 15:48:28 +03:00
'authenticatior' => [
'class' => QueryParamAuth::class, //implement access token authentication
'except' => ['login'], // no need to verify the access token method, pay attention to distinguish between $noAclLogin
],
2021-08-05 18:41:09 +03:00
// 'corsFilter' => [
// 'class' => GsCors::class,
// 'cors' => [
// 'Origin' => ['https://itguild.info'],
// //'Access-Control-Allow-Credentials' => true,
// 'Access-Control-Allow-Headers' => [
// 'Content-Type',
// 'Access-Control-Allow-Headers',
// 'Authorization',
// 'X-Requested-With'
// ],
// ]
// ]
2021-06-25 18:11:30 +03:00
];
}
public function actionIndex($id = null)
{
$searchModel = new ProfileSearchForm();
$searchModel->attributes = \Yii::$app->request->get();
2021-07-03 15:15:54 +03:00
if ($id) {
2021-06-25 18:11:30 +03:00
return $searchModel->byId();
}
return $searchModel->byParams();
}
2021-07-03 15:15:54 +03:00
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'];
}
}
2021-06-25 18:11:30 +03:00
}