the method was moved UserCard to Profile

This commit is contained in:
iironside
2022-03-21 19:08:39 +03:00
parent d11deb20af
commit 16db7b42d9
5 changed files with 143 additions and 54 deletions

View File

@ -8,13 +8,32 @@ use common\models\UserCard;
use frontend\modules\api\models\ProfileSearchForm;
use Yii;
use yii\web\BadRequestHttpException;
use yii\web\ServerErrorHttpException;
class ProfileService
{
/**
* @throws ServerErrorHttpException
*/
public static function getMainData($user_id): array
{
$userCard = UserCard::findOne(['id_user' => $user_id]);
if (empty($userCard)) {
throw new ServerErrorHttpException(json_encode($userCard->errors));
}
return array('fio' => $userCard->fio,
'photo' => $userCard->photo,
'gender' => $userCard->gender,
'level' => $userCard->level,
'years_of_exp' => $userCard->years_of_exp,
'specification' => $userCard->specification,
'position_name' => $userCard->position->name);
}
/**
* @throws BadRequestHttpException
*/
public static function getProfile($id, $request): ?array
public static function getProfile($id, $request)//: ?array
{
$searchModel = new ProfileSearchForm();
$searchModel->attributes = $request;