| Current Path : /var/www/html/chatbot/backend/controllers/application/ |
| Current File : /var/www/html/chatbot/backend/controllers/application/AiDirectorownerController.php |
<?php
namespace backend\controllers\application;
use Yii;
use backend\models\application\AiDirectorowner;
use backend\models\application\AiDirectorownerSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* AiDirectorownerController implements the CRUD actions for AiDirectorowner model.
*/
class AiDirectorownerController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* Lists all AiDirectorowner models.
* @return mixed
*/
public function actionIndex($id)
{
$searchModel = new AiDirectorownerSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams, $id);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'id' => $id,
]);
}
/**
* Displays a single AiDirectorowner 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 AiDirectorowner model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate($id)
{
$model = new AiDirectorowner();
if ($model->load(Yii::$app->request->post())) {
$mapps = AiApplication::findOne($id);
$model->aiad_applicationid = $mapps->aiap_uuid;
$model->aiad_applicationid = $id;
$model->aiad_appoinmentdate = date('Y-m-d', strtotime($model->aiad_appoinmentdate));
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 AiDirectorowner 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->aiad_appoinmentdate = date('Y-m-d', strtotime($model->aiad_appoinmentdate));
if ($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 AiDirectorowner 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(['index']);
}
/**
* Finds the AiDirectorowner model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return AiDirectorowner the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = AiDirectorowner::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException(Yii::t('app', 'The requested page does not exist.'));
}
}