Commit 44ccbb66 by dianc

Category Updated

parent 38ee261d
...@@ -5,6 +5,8 @@ namespace backend\modules\theme\controllers; ...@@ -5,6 +5,8 @@ namespace backend\modules\theme\controllers;
use Yii; use Yii;
use common\models\Category; use common\models\Category;
use backend\modules\theme\models\search\CategorySearch; use backend\modules\theme\models\search\CategorySearch;
use yii\behaviors\SluggableBehavior;
use yii\behaviors\TimestampBehavior;
use yii\web\Controller; use yii\web\Controller;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
...@@ -23,6 +25,15 @@ class CategoryController extends Controller ...@@ -23,6 +25,15 @@ class CategoryController extends Controller
'delete' => ['post'], 'delete' => ['post'],
], ],
], ],
[
'class' => SluggableBehavior::className(),
'attribute' => 'name',
],
[
'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at'
]
]; ];
} }
......
...@@ -13,22 +13,34 @@ use yii\bootstrap\ActiveForm; ...@@ -13,22 +13,34 @@ use yii\bootstrap\ActiveForm;
<?php $form = ActiveForm::begin(); ?> <?php $form = ActiveForm::begin(); ?>
<?php echo $form->errorSummary($model); ?> <?php echo $form->errorSummary($model); ?>
<div class="row">
<div class="col-md-3">
<?php echo $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
</div>
<div class="col-md-3">
<?php echo $form->field($model, 'description')->textarea(['maxlength' => true]) ?>
</div>
</div>
<?php echo $form->field($model, 'name')->textInput(['maxlength' => true]) ?> <div class="row">
<div class="col-md-3">
<?php echo $form->field($model, 'slug')->textInput(['maxlength' => true]) ?> <?php echo $form->field($model, 'slug')->textInput(['maxlength' => true]) ?>
</div>
<?php echo $form->field($model, 'description')->textInput(['maxlength' => true]) ?> <div class="col-md-3">
<?= $form->field($model, 'status')->dropDownList($model::statuses(), ['prompt' => '']) ?>
<?php echo $form->field($model, 'image_url')->textInput(['maxlength' => true]) ?> </div>
</div>
<?php echo $form->field($model, 'image_path')->textInput(['maxlength' => true]) ?> <div class="row">
<div class="col-md-3">
<?php echo $form->field($model, 'status')->textInput() ?> <?= $form->field($model, 'image_url')->widget(
\trntv\filekit\widget\Upload::className(),
<?php echo $form->field($model, 'created_at')->textInput() ?> [
'url' => ['/file-storage/upload'],
<?php echo $form->field($model, 'updated_at')->textInput() ?> ])->label('Image(1280x854)');
?>
</div>
</div>
<div class="form-group"> <div class="form-group">
<?php echo Html::submitButton($model->isNewRecord ? Yii::t('backend', 'Create') : Yii::t('backend', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> <?php echo Html::submitButton($model->isNewRecord ? Yii::t('backend', 'Create') : Yii::t('backend', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
......
...@@ -23,8 +23,8 @@ use common\models\query\CategoryQuery; ...@@ -23,8 +23,8 @@ use common\models\query\CategoryQuery;
class Category extends \yii\db\ActiveRecord class Category extends \yii\db\ActiveRecord
{ {
const STATUS_ACTIVE = 1; const STATUS_ACTIVE = 1;
const STATUS_NOT_ACTIVE = 2; const STATUS_IN_ACTIVE = 2;
const STATUS_DELETED = 3;
/** /**
* @inheritdoc * @inheritdoc
...@@ -87,8 +87,7 @@ class Category extends \yii\db\ActiveRecord ...@@ -87,8 +87,7 @@ class Category extends \yii\db\ActiveRecord
{ {
return [ return [
self::STATUS_ACTIVE => Yii::t('common', 'Active'), self::STATUS_ACTIVE => Yii::t('common', 'Active'),
self::STATUS_NOT_ACTIVE => Yii::t('common', 'Not Active'), self::STATUS_IN_ACTIVE => Yii::t('common', 'In Active'),
self::STATUS_DELETED => Yii::t('common', 'Deleted')
]; ];
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment