api search profile

This commit is contained in:
andrey
2021-06-25 18:11:30 +03:00
parent 1a4f0b6d5e
commit 96a8a530ed
3 changed files with 117 additions and 0 deletions

View File

@ -0,0 +1,49 @@
<?php
namespace frontend\modules\api\controllers;
use common\behaviors\GsCors;
use common\classes\Debug;
use frontend\modules\api\models\ProfileSearchForm;
class ProfileController extends \yii\rest\Controller
{
public function behaviors()
{
return [
[
'class' => \yii\filters\ContentNegotiator::className(),
'formats' => [
'application/json' => \yii\web\Response::FORMAT_JSON,
],
],
'corsFilter' => [
'class' => GsCors::class,
'cors' => [
'Origin' => ['*'],
//'Access-Control-Allow-Credentials' => true,
'Access-Control-Allow-Headers' => [
'Content-Type',
'Access-Control-Allow-Headers',
'Authorization',
'X-Requested-With'
],
]
]
];
}
public function actionIndex($id = null)
{
$searchModel = new ProfileSearchForm();
$searchModel->attributes = \Yii::$app->request->get();
if ($id){
return $searchModel->byId();
}
return $searchModel->byParams();
}
}