From 05711f0d668ed0d1b10f4bd6bd1f26f8be14df32 Mon Sep 17 00:00:00 2001 From: aneenashaju Date: Thu, 4 Jul 2019 10:57:57 +0530 Subject: [PATCH 1/2] crud generation --- yii-gii/README.md | 180 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+) diff --git a/yii-gii/README.md b/yii-gii/README.md index 8dd5638..c2f3ef7 100644 --- a/yii-gii/README.md +++ b/yii-gii/README.md @@ -71,3 +71,183 @@ To generate migration ## customization TBD + +### CRUD GENERATION + +- CRUD stands for create-read-update-delete + + - In gii.yml file + + ``` + crud: + customer_group: + modelClass: codexten\ecommerce\core\models\CustomerGroup + namespace: codexten\ecommerce\admin\ + ``` + + - Run the command in Terminal + + `./vendor/bin/hidev gii/crud packagename ` + +- CustomerGroup controller will be created automatically in the location ecommerce->src->admin->controllers + + CustomerGroupController.php + + ``` + namespace codexten\ecommerce\admin\controllers; + + use Yii; + use codexten\ecommerce\core\models\CustomerGroup; + use codexten\yii\web\CrudController; + + class CustomerGroupController extends CrudController + { + public $modelClass = CustomerGroup::class; + + public function actions() + { + $actions = parent::actions(); + + return $actions; + } + + } + ``` + +- _form.php, create.php, update.php, index.php, view.php will be created automatically in the location ecommerce->src->admin->views->customer_group + + + +_form.php file + +``` +use codexten\ecommerce\core\models\CustomerGroup; +use yii\bootstrap\ActiveForm; +use yii\helpers\Html; + +/* @var $this yii\web\View */ +/* @var $model CustomerGroup */ +?> + +
+
+ + + + field($model, 'code') ?> + + field($model, 'name') ?> + +
+ + isNewRecord ? Yii::t('codexten:module:core', 'Create') : Yii::t('codexten:module:core', 'Update'), + ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> + +
+ + + +
+
+``` + + + +index.php file + +``` +title = Yii::t('codexten:module:core', 'Customer Groups'); +?> + + $this->title, +]) ?> + +beginContent('main-actions') ?> + +renderButton('create', ['create'], ['class' => ['btn-success']]) ?> + +endContent() ?> + +beginContent('table') ?> + + $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + 'code', + 'name', + [ + 'class' => 'yii\grid\ActionColumn', + 'options' => ['style' => 'width: 5%'], + 'template' => '{update} {delete}', + ], + ], +]); ?> + +endContent() ?> + +end() ?> +``` + + + +update.php file + +``` +use codexten\yii\web\widgets\UpdatePage; + +/* @var $this yii\web\View */ +/* @var $model codexten\ecommerce\core\models\CustomerGroup */ + +$this->title = Yii::t('codexten:module:core', 'Update Customer Group: ' . $model->name, [ + 'nameAttribute' => '' . $model->name, +]); +?> + + +beginContent('form') ?> + +render('_form', ['model' => $model]) ?> + +endContent() ?> + +end() ?> +``` + +​ + +create.php file + +``` +title = Yii::t('codexten:module:core', 'Create Customer Group'); +?> + + +beginContent('form') ?> + +render('_form', ['model' => $model]) ?> + +endContent() ?> + +end() ?> +``` + +​ \ No newline at end of file From c0e8242b9abbcf23475403df44414a60eac81a8b Mon Sep 17 00:00:00 2001 From: aneenashaju Date: Thu, 4 Jul 2019 11:20:50 +0530 Subject: [PATCH 2/2] crud generation --- yii-gii/README.md | 144 ---------------------------------------------- 1 file changed, 144 deletions(-) diff --git a/yii-gii/README.md b/yii-gii/README.md index c2f3ef7..7e6aab0 100644 --- a/yii-gii/README.md +++ b/yii-gii/README.md @@ -89,165 +89,21 @@ TBD `./vendor/bin/hidev gii/crud packagename ` -- CustomerGroup controller will be created automatically in the location ecommerce->src->admin->controllers - - CustomerGroupController.php - - ``` - namespace codexten\ecommerce\admin\controllers; - - use Yii; - use codexten\ecommerce\core\models\CustomerGroup; - use codexten\yii\web\CrudController; - - class CustomerGroupController extends CrudController - { - public $modelClass = CustomerGroup::class; - public function actions() - { - $actions = parent::actions(); - - return $actions; - } - - } - ``` - -- _form.php, create.php, update.php, index.php, view.php will be created automatically in the location ecommerce->src->admin->views->customer_group - - - -_form.php file - -``` -use codexten\ecommerce\core\models\CustomerGroup; -use yii\bootstrap\ActiveForm; -use yii\helpers\Html; - -/* @var $this yii\web\View */ -/* @var $model CustomerGroup */ -?> -
-
- - - field($model, 'code') ?> - - field($model, 'name') ?> - -
- - isNewRecord ? Yii::t('codexten:module:core', 'Create') : Yii::t('codexten:module:core', 'Update'), - ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> - -
- - - -
-
-``` - - - -index.php file - -``` -title = Yii::t('codexten:module:core', 'Customer Groups'); -?> - $this->title, -]) ?> -beginContent('main-actions') ?> -renderButton('create', ['create'], ['class' => ['btn-success']]) ?> -endContent() ?> - -beginContent('table') ?> - - $dataProvider, - 'filterModel' => $searchModel, - 'columns' => [ - 'code', - 'name', - [ - 'class' => 'yii\grid\ActionColumn', - 'options' => ['style' => 'width: 5%'], - 'template' => '{update} {delete}', - ], - ], -]); ?> - -endContent() ?> - -end() ?> -``` - - - -update.php file - -``` -use codexten\yii\web\widgets\UpdatePage; - -/* @var $this yii\web\View */ -/* @var $model codexten\ecommerce\core\models\CustomerGroup */ - -$this->title = Yii::t('codexten:module:core', 'Update Customer Group: ' . $model->name, [ - 'nameAttribute' => '' . $model->name, -]); -?> - - -beginContent('form') ?> - -render('_form', ['model' => $model]) ?> - -endContent() ?> - -end() ?> -``` ​ -create.php file - -``` -title = Yii::t('codexten:module:core', 'Create Customer Group'); -?> - -beginContent('form') ?> -render('_form', ['model' => $model]) ?> - -endContent() ?> - -end() ?> -``` ​ \ No newline at end of file