| Current Path : /var/www/html/chatbot/backend/controllers/application/ |
| Current File : /var/www/html/chatbot/backend/controllers/application/AiAuthorizeduserController.php |
<?php
namespace backend\controllers\application;
use Yii;
use backend\models\application\AiAuthorizeduser;
use backend\models\application\AiAuthorizeduserSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* AiAuthorizeduserController implements the CRUD actions for AiAuthorizeduser model.
*/
class AiAuthorizeduserController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* Lists all AiAuthorizeduser models.
* @return mixed
*/
public function actionIndex($id)
{
$searchModel = new AiAuthorizeduserSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams, $id);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'id' => $id,
]);
}
/**
* Displays a single AiAuthorizeduser model.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new AiAuthorizeduser model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate($id)
{
$model = new AiAuthorizeduser();
if ($model->load(Yii::$app->request->post())) {
$mapps = AiApplication::findOne($id);
$model->aiau_uuid = $mapps->aiap_uuid;
$model->aiau_applicationid = $id;
if ($model->save()) {
Yii::$app->session->setFlash('success', Yii::$app->params['successCreate']);
return $this->redirect(Yii::$app->request->referrer);
}
}
return $this->renderAjax('create', [
'model' => $model,
]);
}
/**
* Updates an existing AiAuthorizeduser model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
Yii::$app->session->setFlash('success', Yii::$app->params['successUpdate']);
return $this->redirect(Yii::$app->request->referrer);
}
return $this->renderAjax('update', [
'model' => $model,
]);
}
/**
* Deletes an existing AiAuthorizeduser model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
Yii::$app->session->setFlash('success', Yii::$app->params['successDelete']);
return $this->redirect(Yii::$app->request->referrer);
}
/**
* Finds the AiAuthorizeduser model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return AiAuthorizeduser the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = AiAuthorizeduser::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException(Yii::t('app', 'The requested page does not exist.'));
}
}