|
|
@ -21,19 +21,19 @@ $actionParamComments = $generator->generateActionParamComments(); |
|
|
|
echo "<?php\n";
|
|
|
|
echo "<?php\n";
|
|
|
|
?> |
|
|
|
?> |
|
|
|
|
|
|
|
|
|
|
|
namespace <?=StringHelper::dirname(ltrim($generator->controllerClass, '\\')); ?>;
|
|
|
|
namespace <?= StringHelper::dirname(ltrim($generator->controllerClass, '\\')) ?>;
|
|
|
|
|
|
|
|
|
|
|
|
use <?=ltrim($generator->modelClass, '\\'); ?>;
|
|
|
|
use <?= ltrim($generator->modelClass, '\\') ?>;
|
|
|
|
use <?=ltrim($generator->searchModelClass, '\\'); ?>;
|
|
|
|
use <?= ltrim($generator->searchModelClass, '\\') ?>;
|
|
|
|
use yii\data\ActiveDataProvider; |
|
|
|
use yii\data\ActiveDataProvider; |
|
|
|
use <?=ltrim($generator->baseControllerClass, '\\'); ?>;
|
|
|
|
use <?= ltrim($generator->baseControllerClass, '\\') ?>;
|
|
|
|
use yii\web\HttpException; |
|
|
|
use yii\web\HttpException; |
|
|
|
use yii\web\VerbFilter; |
|
|
|
use yii\web\VerbFilter; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* <?=$controllerClass; ?> implements the CRUD actions for <?=$modelClass; ?> model.
|
|
|
|
* <?= $controllerClass ?> implements the CRUD actions for <?= $modelClass ?> model.
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class <?=$controllerClass; ?> extends <?=StringHelper::basename($generator->baseControllerClass) . "\n"; ?> |
|
|
|
class <?= $controllerClass ?> extends <?= StringHelper::basename($generator->baseControllerClass) . "\n" ?> |
|
|
|
{ |
|
|
|
{ |
|
|
|
public function behaviors() |
|
|
|
public function behaviors() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -48,12 +48,12 @@ class <?=$controllerClass; ?> extends <?=StringHelper::basename($generator->base |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Lists all <?=$modelClass; ?> models.
|
|
|
|
* Lists all <?= $modelClass ?> models.
|
|
|
|
* @return mixed |
|
|
|
* @return mixed |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function actionIndex() |
|
|
|
public function actionIndex() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$searchModel = new <?=$searchModelClass; ?>;
|
|
|
|
$searchModel = new <?= $searchModelClass ?>;
|
|
|
|
$dataProvider = $searchModel->search($_GET); |
|
|
|
$dataProvider = $searchModel->search($_GET); |
|
|
|
|
|
|
|
|
|
|
|
return $this->render('index', [ |
|
|
|
return $this->render('index', [ |
|
|
@ -63,28 +63,28 @@ class <?=$controllerClass; ?> extends <?=StringHelper::basename($generator->base |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Displays a single <?=$modelClass; ?> model.
|
|
|
|
* Displays a single <?= $modelClass ?> model.
|
|
|
|
* <?=implode("\n\t * ", $actionParamComments) . "\n"; ?> |
|
|
|
* <?= implode("\n\t * ", $actionParamComments) . "\n" ?> |
|
|
|
* @return mixed |
|
|
|
* @return mixed |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function actionView(<?=$actionParams; ?>)
|
|
|
|
public function actionView(<?= $actionParams ?>)
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return $this->render('view', [ |
|
|
|
return $this->render('view', [ |
|
|
|
'model' => $this->findModel(<?=$actionParams; ?>),
|
|
|
|
'model' => $this->findModel(<?= $actionParams ?>),
|
|
|
|
]); |
|
|
|
]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Creates a new <?=$modelClass; ?> model.
|
|
|
|
* Creates a new <?= $modelClass ?> model.
|
|
|
|
* If creation is successful, the browser will be redirected to the 'view' page. |
|
|
|
* If creation is successful, the browser will be redirected to the 'view' page. |
|
|
|
* @return mixed |
|
|
|
* @return mixed |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function actionCreate() |
|
|
|
public function actionCreate() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$model = new <?=$modelClass; ?>;
|
|
|
|
$model = new <?= $modelClass ?>;
|
|
|
|
|
|
|
|
|
|
|
|
if ($model->load($_POST) && $model->save()) { |
|
|
|
if ($model->load($_POST) && $model->save()) { |
|
|
|
return $this->redirect(['view', <?=$urlParams; ?>]);
|
|
|
|
return $this->redirect(['view', <?= $urlParams ?>]);
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return $this->render('create', [ |
|
|
|
return $this->render('create', [ |
|
|
|
'model' => $model, |
|
|
|
'model' => $model, |
|
|
@ -93,17 +93,17 @@ class <?=$controllerClass; ?> extends <?=StringHelper::basename($generator->base |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Updates an existing <?=$modelClass; ?> model.
|
|
|
|
* Updates an existing <?= $modelClass ?> model.
|
|
|
|
* If update is successful, the browser will be redirected to the 'view' page. |
|
|
|
* If update is successful, the browser will be redirected to the 'view' page. |
|
|
|
* <?=implode("\n\t * ", $actionParamComments) . "\n"; ?> |
|
|
|
* <?= implode("\n\t * ", $actionParamComments) . "\n" ?> |
|
|
|
* @return mixed |
|
|
|
* @return mixed |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function actionUpdate(<?=$actionParams; ?>)
|
|
|
|
public function actionUpdate(<?= $actionParams ?>)
|
|
|
|
{ |
|
|
|
{ |
|
|
|
$model = $this->findModel(<?=$actionParams; ?>);
|
|
|
|
$model = $this->findModel(<?= $actionParams ?>);
|
|
|
|
|
|
|
|
|
|
|
|
if ($model->load($_POST) && $model->save()) { |
|
|
|
if ($model->load($_POST) && $model->save()) { |
|
|
|
return $this->redirect(['view', <?=$urlParams; ?>]);
|
|
|
|
return $this->redirect(['view', <?= $urlParams ?>]);
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return $this->render('update', [ |
|
|
|
return $this->render('update', [ |
|
|
|
'model' => $model, |
|
|
|
'model' => $model, |
|
|
@ -112,25 +112,25 @@ class <?=$controllerClass; ?> extends <?=StringHelper::basename($generator->base |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Deletes an existing <?=$modelClass; ?> model.
|
|
|
|
* Deletes an existing <?= $modelClass ?> model.
|
|
|
|
* If deletion is successful, the browser will be redirected to the 'index' page. |
|
|
|
* If deletion is successful, the browser will be redirected to the 'index' page. |
|
|
|
* <?=implode("\n\t * ", $actionParamComments) . "\n"; ?> |
|
|
|
* <?= implode("\n\t * ", $actionParamComments) . "\n" ?> |
|
|
|
* @return mixed |
|
|
|
* @return mixed |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function actionDelete(<?=$actionParams; ?>)
|
|
|
|
public function actionDelete(<?= $actionParams ?>)
|
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->findModel(<?=$actionParams; ?>)->delete();
|
|
|
|
$this->findModel(<?= $actionParams ?>)->delete();
|
|
|
|
return $this->redirect(['index']); |
|
|
|
return $this->redirect(['index']); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Finds the <?=$modelClass; ?> model based on its primary key value.
|
|
|
|
* Finds the <?= $modelClass ?> model based on its primary key value.
|
|
|
|
* If the model is not found, a 404 HTTP exception will be thrown. |
|
|
|
* If the model is not found, a 404 HTTP exception will be thrown. |
|
|
|
* <?=implode("\n\t * ", $actionParamComments) . "\n"; ?> |
|
|
|
* <?= implode("\n\t * ", $actionParamComments) . "\n" ?> |
|
|
|
* @return <?=$modelClass; ?> the loaded model
|
|
|
|
* @return <?= $modelClass ?> the loaded model
|
|
|
|
* @throws HttpException if the model cannot be found |
|
|
|
* @throws HttpException if the model cannot be found |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected function findModel(<?=$actionParams; ?>)
|
|
|
|
protected function findModel(<?= $actionParams ?>)
|
|
|
|
{ |
|
|
|
{ |
|
|
|
<?php |
|
|
|
<?php |
|
|
|
if (count($pks) === 1) { |
|
|
|
if (count($pks) === 1) { |
|
|
@ -143,7 +143,7 @@ if (count($pks) === 1) { |
|
|
|
$condition = '[' . implode(', ', $condition) . ']'; |
|
|
|
$condition = '[' . implode(', ', $condition) . ']'; |
|
|
|
} |
|
|
|
} |
|
|
|
?> |
|
|
|
?> |
|
|
|
if (($model = <?=$modelClass; ?>::find(<?=$condition; ?>)) !== null) {
|
|
|
|
if (($model = <?= $modelClass ?>::find(<?= $condition ?>)) !== null) {
|
|
|
|
return $model; |
|
|
|
return $model; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
throw new HttpException(404, 'The requested page does not exist.'); |
|
|
|
throw new HttpException(404, 'The requested page does not exist.'); |
|
|
|