adding forgotten files for last commit
This commit is contained in:
24
backend/modules/api/Api.php
Normal file
24
backend/modules/api/Api.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\api;
|
||||
|
||||
/**
|
||||
* api module definition class
|
||||
*/
|
||||
class Api extends \yii\base\Module
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public $controllerNamespace = 'backend\modules\api\controllers';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
// custom initialization code goes here
|
||||
}
|
||||
}
|
20
backend/modules/api/controllers/DefaultController.php
Normal file
20
backend/modules/api/controllers/DefaultController.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\api\controllers;
|
||||
|
||||
use yii\web\Controller;
|
||||
|
||||
/**
|
||||
* Default controller for the `api` module
|
||||
*/
|
||||
class DefaultController extends Controller
|
||||
{
|
||||
/**
|
||||
* Renders the index view for the module
|
||||
* @return string
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('index');
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\api\controllers;
|
||||
|
||||
use yii\filters\auth\CompositeAuth;
|
||||
use yii\filters\auth\HttpBearerAuth;
|
||||
use yii\rest\Controller;
|
||||
|
||||
class UserQuestionnaireController extends Controller
|
||||
{
|
||||
public $modelClass = 'backend/modules/api/models/UserQuestionnaire';
|
||||
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'class' => \yii\filters\ContentNegotiator::className(),
|
||||
'formats' => [
|
||||
'application/json' => \yii\web\Response::FORMAT_JSON,
|
||||
],
|
||||
],
|
||||
// 'authenticator' => [
|
||||
// 'class' => CompositeAuth::class,
|
||||
// 'authMethods' => [
|
||||
// HttpBearerAuth::class,
|
||||
// ],
|
||||
// ]
|
||||
];
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
return ['some' => 'rrr'];
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @inheritdoc
|
||||
// */
|
||||
// protected function verbs()
|
||||
// {
|
||||
// return [
|
||||
// 'index' => ['GET', 'HEAD'],
|
||||
// ];
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
96
backend/modules/api/models/User.php
Normal file
96
backend/modules/api/models/User.php
Normal file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\api\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "user".
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $username
|
||||
* @property string $auth_key
|
||||
* @property string $password_hash
|
||||
* @property string $password_reset_token
|
||||
* @property string $email
|
||||
* @property int $status
|
||||
* @property int $created_at
|
||||
* @property int $updated_at
|
||||
* @property string $access_token
|
||||
* @property string $access_token_expired_at
|
||||
*
|
||||
* @property UserCard[] $userCards
|
||||
* @property UserQuestionnaire[] $userQuestionnaires
|
||||
* @property UserResponse[] $userResponses
|
||||
*/
|
||||
class User extends \common\models\User
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'user';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['username', 'auth_key', 'password_hash', 'email', 'created_at', 'updated_at'], 'required'],
|
||||
[['status', 'created_at', 'updated_at'], 'integer'],
|
||||
[['access_token_expired_at'], 'safe'],
|
||||
[['username', 'password_hash', 'password_reset_token', 'email', 'access_token'], 'string', 'max' => 255],
|
||||
[['auth_key'], 'string', 'max' => 32],
|
||||
[['username'], 'unique'],
|
||||
[['email'], 'unique'],
|
||||
[['password_reset_token'], 'unique'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'username' => 'Username',
|
||||
'auth_key' => 'Auth Key',
|
||||
'password_hash' => 'Password Hash',
|
||||
'password_reset_token' => 'Password Reset Token',
|
||||
'email' => 'Email',
|
||||
'status' => 'Status',
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
'access_token' => 'Access Token',
|
||||
'access_token_expired_at' => 'Access Token Expired At',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getUserCards()
|
||||
{
|
||||
return $this->hasMany(UserCard::className(), ['id_user' => 'id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getUserQuestionnaires()
|
||||
{
|
||||
return $this->hasMany(UserQuestionnaire::className(), ['user_id' => 'id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getUserResponses()
|
||||
{
|
||||
return $this->hasMany(UserResponse::className(), ['user_id' => 'id']);
|
||||
}
|
||||
}
|
9
backend/modules/api/models/UserQuestionnaire.php
Normal file
9
backend/modules/api/models/UserQuestionnaire.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\api\models;
|
||||
|
||||
|
||||
class UserQuestionnaire extends \common\models\UserQuestionnaire
|
||||
{
|
||||
|
||||
}
|
12
backend/modules/api/views/default/index.php
Normal file
12
backend/modules/api/views/default/index.php
Normal file
@ -0,0 +1,12 @@
|
||||
<div class="api-default-index">
|
||||
<h1><?= $this->context->action->uniqueId ?></h1>
|
||||
<p>
|
||||
This is the view content for action "<?= $this->context->action->id ?>".
|
||||
The action belongs to the controller "<?= get_class($this->context) ?>"
|
||||
in the "<?= $this->context->module->id ?>" module.
|
||||
</p>
|
||||
<p>
|
||||
You may customize this page by editing the following file:<br>
|
||||
<code><?= __FILE__ ?></code>
|
||||
</p>
|
||||
</div>
|
9
backend/modules/api/views/user-questionnaire/index.php
Normal file
9
backend/modules/api/views/user-questionnaire/index.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
/* @var $this yii\web\View */
|
||||
?>
|
||||
<h1>user-questionnaire/index</h1>
|
||||
|
||||
<p>
|
||||
You may change the content of this page by modifying
|
||||
the file <code><?= __FILE__; ?></code>.
|
||||
</p>
|
Reference in New Issue
Block a user