2021-06-25 18:11:30 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace frontend\modules\api\controllers;
|
|
|
|
|
2022-01-14 10:09:02 +03:00
|
|
|
use common\services\ProfileService;
|
2022-10-19 15:28:09 +03:00
|
|
|
use yii\helpers\ArrayHelper;
|
2022-01-14 10:09:02 +03:00
|
|
|
use yii\web\BadRequestHttpException;
|
2022-10-19 15:28:09 +03:00
|
|
|
use yii\web\NotFoundHttpException;
|
2022-03-21 19:08:39 +03:00
|
|
|
use yii\web\ServerErrorHttpException;
|
2022-01-14 12:56:39 +03:00
|
|
|
|
2021-11-29 18:21:50 +03:00
|
|
|
class ProfileController extends ApiController
|
2021-06-25 18:11:30 +03:00
|
|
|
{
|
2022-10-19 15:28:09 +03:00
|
|
|
|
|
|
|
public function behaviors(): array
|
2021-06-25 18:11:30 +03:00
|
|
|
{
|
2022-10-19 15:28:09 +03:00
|
|
|
return ArrayHelper::merge(parent::behaviors(), [
|
|
|
|
|
|
|
|
'verbs' => [
|
|
|
|
'class' => \yii\filters\VerbFilter::class,
|
|
|
|
'actions' => [
|
2023-01-13 15:46:15 +03:00
|
|
|
'' => ['GET', 'HEAD', 'OPTIONS'],
|
2022-10-19 15:28:09 +03:00
|
|
|
'profile-with-report-permission' => ['post', 'patch'],
|
|
|
|
'get-main-data' => ['get']
|
|
|
|
],
|
|
|
|
]
|
|
|
|
]);
|
2021-06-25 18:11:30 +03:00
|
|
|
}
|
|
|
|
|
2022-10-19 15:28:09 +03:00
|
|
|
/**
|
|
|
|
* @throws NotFoundHttpException
|
|
|
|
*/
|
2022-03-21 19:08:39 +03:00
|
|
|
public function actionIndex($id = null): ?array
|
2021-06-25 18:11:30 +03:00
|
|
|
{
|
2022-10-19 15:42:26 +03:00
|
|
|
return ProfileService::getProfile($id, \Yii::$app->request->get());
|
2021-07-03 15:15:54 +03:00
|
|
|
}
|
|
|
|
|
2022-03-21 14:56:21 +03:00
|
|
|
/**
|
|
|
|
* @throws BadRequestHttpException
|
|
|
|
*/
|
|
|
|
public function actionProfileWithReportPermission($id): ?array
|
2021-09-07 16:32:57 +03:00
|
|
|
{
|
2022-03-21 14:56:21 +03:00
|
|
|
return ProfileService::getProfileWithReportPermission($id);
|
2021-09-07 16:32:57 +03:00
|
|
|
}
|
2022-03-21 19:08:39 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @throws ServerErrorHttpException
|
|
|
|
*/
|
|
|
|
public function actionGetMainData($user_id): array
|
|
|
|
{
|
|
|
|
return ProfileService::getMainData($user_id);
|
|
|
|
}
|
2022-12-27 11:45:28 +03:00
|
|
|
|
|
|
|
public function actionPortfolioProjects($card_id): array
|
|
|
|
{
|
|
|
|
return ProfileService::getPortfolioProjects($card_id);
|
|
|
|
}
|
2022-03-21 14:56:21 +03:00
|
|
|
}
|