prolab-api/backend/controllers/LisLabCodeMappingController...

148 lines
4.0 KiB
PHP

<?php
namespace backend\controllers;
use common\models\LISLabCodeMapping;
use backend\models\LISLabCodeMappingSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* LisLabCodeMappingController implements the CRUD actions for LISLabCodeMapping model.
*/
class LisLabCodeMappingController extends Controller
{
/**
* @inheritDoc
*/
public function behaviors()
{
return array_merge(
parent::behaviors(),
[
'access' => [
'class' => \yii\filters\AccessControl::class,
'rules' => [
[
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::class,
'actions' => [
'delete' => ['POST'],
],
],
]
);
}
/**
* Lists all LISLabCodeMapping models.
*
* @return string
*/
public function actionIndex()
{
$searchModel = new LISLabCodeMappingSearch();
$dataProvider = $searchModel->search($this->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single LISLabCodeMapping model.
* @param string $TestID Test ID
* @param string $PROLAB_LabID Prolab Lab ID
* @return string
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionView($TestID, $PROLAB_LabID)
{
return $this->render('view', [
'model' => $this->findModel($TestID, $PROLAB_LabID),
]);
}
/**
* Creates a new LISLabCodeMapping model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return string|\yii\web\Response
*/
public function actionCreate()
{
$model = new LISLabCodeMapping();
if ($this->request->isPost) {
if ($model->load($this->request->post()) && $model->save()) {
return $this->redirect(['view', 'TestID' => $model->TestID, 'PROLAB_LabID' => $model->PROLAB_LabID]);
}
} else {
$model->loadDefaultValues();
}
return $this->render('create', [
'model' => $model,
]);
}
/**
* Updates an existing LISLabCodeMapping model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param string $TestID Test ID
* @param string $PROLAB_LabID Prolab Lab ID
* @return string|\yii\web\Response
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionUpdate($TestID, $PROLAB_LabID)
{
$model = $this->findModel($TestID, $PROLAB_LabID);
if ($this->request->isPost && $model->load($this->request->post()) && $model->save()) {
return $this->redirect(['view', 'TestID' => $model->TestID, 'PROLAB_LabID' => $model->PROLAB_LabID]);
}
return $this->render('update', [
'model' => $model,
]);
}
/**
* Deletes an existing LISLabCodeMapping model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param string $TestID Test ID
* @param string $PROLAB_LabID Prolab Lab ID
* @return \yii\web\Response
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionDelete($TestID, $PROLAB_LabID)
{
$this->findModel($TestID, $PROLAB_LabID)->delete();
return $this->redirect(['index']);
}
/**
* Finds the LISLabCodeMapping model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param string $TestID Test ID
* @param string $PROLAB_LabID Prolab Lab ID
* @return LISLabCodeMapping the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($TestID, $PROLAB_LabID)
{
if (($model = LISLabCodeMapping::findOne(['TestID' => $TestID, 'PROLAB_LabID' => $PROLAB_LabID])) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
}