Commit 7f91e429 by Junaid Rahman pv

some bug fix

parent eba4f238
...@@ -40,11 +40,11 @@ $this->params['breadcrumbs'][] = $this->title; ...@@ -40,11 +40,11 @@ $this->params['breadcrumbs'][] = $this->title;
'enum' => Category::statuses(), 'enum' => Category::statuses(),
'filter' => Category::statuses() 'filter' => Category::statuses()
], ],
'created_at', 'created_at:datetime',
// 'updated_at', // 'updated_at',
['class' => 'yii\grid\ActionColumn', ['class' => 'yii\grid\ActionColumn',
'template' => '{update}{delete}'], 'template' => '{update} {delete}'],
], ],
]); ?> ]); ?>
......
...@@ -10,38 +10,35 @@ use yii\helpers\Html; ...@@ -10,38 +10,35 @@ use yii\helpers\Html;
?> ?>
<div class="text-block-form"> <div class="text-block-form">
<?php $form = ActiveForm::begin(); ?> <?php $form = ActiveForm::begin(); ?>
<?php <?php
$file = yii::getAlias('@storage/private/theme-assets/') . $model->theme_code . '/' . $model->file_code; $file = yii::getAlias('@storage/private/theme-assets/') . $model->theme_code . '/' . $model->file_code;
$model->fileContent = file_get_contents($file); $model->fileContent = file_get_contents($file);
?> ?>
<div class="page-header">
<h4> <b>Theme code: </b>
<?=$model->theme_code?>
<br><br><b>File code:</b>
<?=$model->file_code?> <div class="row">
<div class="col-md-6">
</h4> <b>File: </b><?= $model->theme_code ?>/<?= $model->file_code ?><br/><br/>
</div>
</div> </div>
<?= $form->field($model, 'fileContent')->widget( <?= $form->field($model, 'fileContent')->widget(
trntv\aceeditor\AceEditor::className(), trntv\aceeditor\AceEditor::className(),
[ [
'mode' => 'html' 'mode' => 'html',
] 'theme' => 'chaos',
) ?> ]
) ?>
<div class="form-group"> <div class="form-group">
<?= Html::submitButton( <?= Html::submitButton(
$model->isNewRecord ? Yii::t('backend', 'Create') : Yii::t('backend', 'Update'), $model->isNewRecord ? Yii::t('backend', 'Create') : Yii::t('backend', 'Update'),
['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary'] [
'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']
) ?> ) ?>
</div> </div>
......
...@@ -27,21 +27,34 @@ class m160830_105840_category extends Migration ...@@ -27,21 +27,34 @@ class m160830_105840_category extends Migration
$this->createTable('{{%category_files}}', [ $this->createTable('{{%category_files}}', [
'id' => $this->primaryKey(), 'id' => $this->primaryKey(),
'category_id' => $this->integer()->notNull(), 'category_id' => $this->integer()->notNull(),
'code' => $this->string(11)->notNull(), 'code' => $this->string(10)->notNull(),
'type' => $this->integer()->notNull(), 'type' => $this->integer()->notNull(),
'name' => $this->string(32)->notNull(), 'name' => $this->string(32)->notNull(),
'created_at' => $this->integer(), 'created_at' => $this->integer(),
'updated_at' => $this->integer() 'updated_at' => $this->integer()
], $tableOptions); ], $tableOptions);
$this->addForeignKey('fk_category', '{{%category_files}}', 'category_id', '{{%category}}', 'id', 'cascade', $this->createIndex('idx_category_name', '{{%category}}', 'name');
'cascade'); $this->createIndex('idx_category_slug', '{{%category}}', 'slug');
$this->createIndex('idx_category_files_category_id', '{{%category_files}}', 'category_id');
$this->createIndex('idx_category_files_code', '{{%category_files}}', 'code');
$this->createIndex('idx_category_files_name', '{{%category_files}}', 'name');
$this->addForeignKey('fk_category', '{{%category_files}}', 'category_id', '{{%category}}', 'id', 'RESTRICT',
'RESTRICT');
} }
public function safeDown() public function safeDown()
{ {
$this->dropForeignKey('fk_category', '{{%category_files}}'); $this->dropForeignKey('fk_category', '{{%category_files}}');
$this->dropTable('{{%category_files}}');
$this->dropIndex('idx_category_files_name', '{{%category_files}}');
$this->dropIndex('idx_category_files_code', '{{%category_files}}');
$this->dropIndex('idx_category_files_category_id', '{{%category_files}}');
$this->dropIndex('idx_category_slug', '{{%category}}');
$this->dropIndex('idx_category_name', '{{%category}}');
$this->dropTable('{{%category_files}}');
$this->dropTable('{{%category}}'); $this->dropTable('{{%category}}');
} }
......
...@@ -15,7 +15,7 @@ class m160903_101233_theme extends Migration ...@@ -15,7 +15,7 @@ class m160903_101233_theme extends Migration
$this->createTable('{{%theme}}', [ $this->createTable('{{%theme}}', [
'id' => $this->primaryKey(), 'id' => $this->primaryKey(),
'category_id' => $this->integer()->notNull(), 'category_id' => $this->integer()->notNull(),
'code' => $this->string(11)->notNull(), 'code' => $this->string(10)->notNull(),
'slug' => $this->string(32)->notNull(), 'slug' => $this->string(32)->notNull(),
'name' => $this->string(32)->notNull(), 'name' => $this->string(32)->notNull(),
'description' => $this->string(512), 'description' => $this->string(512),
...@@ -26,16 +26,24 @@ class m160903_101233_theme extends Migration ...@@ -26,16 +26,24 @@ class m160903_101233_theme extends Migration
$this->createTable('{{%theme_files}}', [ $this->createTable('{{%theme_files}}', [
'id' => $this->primaryKey(), 'id' => $this->primaryKey(),
'theme_code' => $this->string(11)->notNull(), 'theme_code' => $this->string(10)->notNull(),
'file_code' => $this->string(11)->notNull(), 'file_code' => $this->string(10)->notNull(),
'created_at' => $this->integer(), 'created_at' => $this->integer(),
'updated_at' => $this->integer() 'updated_at' => $this->integer()
], $tableOptions); ], $tableOptions);
$this->createIndex('idx_theme_code', '{{%theme}}', 'code');
$this->createIndex('idx_theme_name', '{{%theme}}', 'name');
$this->createIndex('idx_theme_slug', '{{%theme}}', 'slug');
$this->createIndex('idx_theme_files_theme_code', '{{%theme_files}}', 'theme_code');
$this->createIndex('idx_theme_files_file_code', '{{%theme_files}}', 'file_code');
$this->addForeignKey('fk_theme_category', '{{%theme}}', 'category_id', '{{%category}}', 'id', 'cascade', 'cascade'); $this->addForeignKey('fk_theme_category', '{{%theme}}', 'category_id', '{{%category}}', 'id', 'RESTRICT',
$this->addForeignKey('fk_theme_files_theme', '{{%theme_files}}', 'theme_code', '{{%theme}}', 'code', 'cascade', 'cascade'); 'RESTRICT');
$this->addForeignKey('fk_theme_category_files', '{{%theme_files}}', 'file_code', '{{%category_files}}', 'code', 'cascade', 'cascade'); $this->addForeignKey('fk_theme_files_theme', '{{%theme_files}}', 'theme_code', '{{%theme}}', 'code', 'RESTRICT',
'RESTRICT');
$this->addForeignKey('fk_theme_files_category_files', '{{%theme_files}}', 'file_code', '{{%category_files}}', 'code',
'cascade', 'cascade');
} }
public function safeDown() public function safeDown()
...@@ -44,6 +52,12 @@ class m160903_101233_theme extends Migration ...@@ -44,6 +52,12 @@ class m160903_101233_theme extends Migration
$this->dropForeignKey('fk_theme_files_theme', '{{%theme_files}}'); $this->dropForeignKey('fk_theme_files_theme', '{{%theme_files}}');
$this->dropForeignKey('fk_theme_category', '{{%theme}}'); $this->dropForeignKey('fk_theme_category', '{{%theme}}');
$this->dropIndex('idx_theme_files_file_code', '{{%theme_files}}');
$this->dropIndex('idx_theme_files_theme_code', '{{%theme_files}}');
$this->dropIndex('idx_theme_slug', '{{%theme}}');
$this->dropIndex('idx_theme_name', '{{%theme}}');
$this->dropIndex('idx_theme_code', '{{%theme}}');
$this->dropTable('{{%theme_files}}'); $this->dropTable('{{%theme_files}}');
$this->dropTable('{{%theme}}'); $this->dropTable('{{%theme}}');
} }
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
namespace common\models; namespace common\models;
use Yii; use Yii;
use yii\behaviors\SluggableBehavior;
use yii\behaviors\TimestampBehavior;
/** /**
* This is the model class for table "{{%theme}}". * This is the model class for table "{{%theme}}".
...@@ -33,6 +35,21 @@ class Theme extends \yii\db\ActiveRecord ...@@ -33,6 +35,21 @@ class Theme extends \yii\db\ActiveRecord
return '{{%theme}}'; return '{{%theme}}';
} }
public function behaviors()
{
return [
[
'class' => SluggableBehavior::className(),
'attribute' => 'name',
'immutable' => true
],
[
'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at'
]
];
}
/** /**
* @inheritdoc * @inheritdoc
*/ */
......
...@@ -115,4 +115,5 @@ class ThemeFiles extends \yii\db\ActiveRecord ...@@ -115,4 +115,5 @@ class ThemeFiles extends \yii\db\ActiveRecord
{ {
return file_exists(self::getFilePath($theme_code,$file_code)); return file_exists(self::getFilePath($theme_code,$file_code));
} }
} }
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