Commit 45d0743a by dianc

Category Files changes

parent 32ec38bf
......@@ -166,7 +166,6 @@ class CategoryController extends Controller
]);
}
/**
* Finds the Category model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
......@@ -183,55 +182,4 @@ class CategoryController extends Controller
}
}
// public function actionCreatee()
// {
// $model = new Category();
// $models = [new CategoryFiles()];
// if ($model->load(Yii::$app->request->post())) {
//
// $models = Model::createMultiple(CategoryFiles::classname());
// Model::loadMultiple($models, Yii::$app->request->post());
//
// // ajax validation
// if (Yii::$app->request->isAjax) {
// Yii::$app->response->format = Response::FORMAT_JSON;
//
// return ArrayHelper::merge(
// ActiveForm::validateMultiple($models),
// ActiveForm::validate($model)
// );
// }
//
// // validate all models
// $valid = $model->validate();
// $valid = Model::validateMultiple($models) && $valid;
//
// if ($valid) {
// $transaction = \Yii::$app->db->beginTransaction();
// try {
// if ($flag = $model->save(false)) {
// foreach ($models as $modelFile) {
// $modelFile->category_id = $model->id;
// if (!($flag = $modelFile->save(false))) {
// $transaction->rollBack();
// break;
// }
// }
// }
// if ($flag) {
// $transaction->commit();
//
// return $this->redirect(['file', 'category_id' => $model->id]);
// }
// } catch (Exception $e) {
// $transaction->rollBack();
// }
// }
// }
//
// return $this->render('file', [
// 'model' => $model,
// 'modelFiles' => (empty($models)) ? [new CategoryFiles()] : $models
// ]);
// }
}
......@@ -44,7 +44,11 @@ $this->params['breadcrumbs'][] = $this->title;
// 'created_at',
// 'updated_at',
['class' => 'yii\grid\ActionColumn'],
['class' => 'yii\grid\ActionColumn'
],
// ['class' => 'yii\grid\ActionColumn',
// 'template' => '{update}{delete}'],
],
]); ?>
......
......@@ -24,9 +24,10 @@ use wbraganca\dynamicform\DynamicFormWidget;
'model' => $modelFiles[0],
'formId' => 'dynamic-form',
'formFields' => [
'name',
'code',
'type',
'theme_code',
'file_code',
'base_url',
'base_path',
],
]); ?>
......
<?php
use yii\helpers\Html;
use yii\grid\GridView;
use common\grid\EnumColumn;
use common\models\Theme;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\theme\models\search\ThemeSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('backend', 'Themes');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="theme-index">
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a(Yii::t('backend', 'Create {modelClass}', [
'modelClass' => 'ThemeFiles',
]), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'theme_code',
'file_code',
'base_url',
'base_path',
// 'description',
// [
// 'class' => EnumColumn::className(),
// 'attribute' => 'status',
// 'enum' => Theme::statuses(),
// 'filter' => Theme::statuses()
// ],
// 'status',
// 'created_at',
// 'updated_at',
// ['class' => 'yii\grid\ActionColumn'
// ],
// ['class' => 'yii\grid\ActionColumn',
// 'template' => '{update}{delete}'],
],
]); ?>
</div>
......@@ -26,8 +26,8 @@ class m160903_101233_theme extends Migration
$this->createTable('{{%theme_files}}', [
'id' => $this->primaryKey(),
'theme_id' => $this->integer()->notNull(),
'file_id' => $this->string(32)->notNull(),
'theme_code' => $this->integer()->notNull(),
'file_code' => $this->integer()->notNull(),
'base_url' => $this->string(1024),
'base_path' => $this->string(1024),
'created_at' => $this->integer(),
......@@ -36,11 +36,13 @@ class m160903_101233_theme extends Migration
$this->addForeignKey('fk_theme_category', '{{%theme}}', 'category_id', '{{%category}}', 'id', 'cascade', 'cascade');
$this->addForeignKey('fk_theme_files_theme', '{{%theme_files}}', 'theme_id', '{{%theme}}', 'id', 'cascade', 'cascade');
$this->addForeignKey('fk_theme_files_theme', '{{%theme_files}}', 'theme_code', '{{%theme}}', 'id', 'cascade', 'cascade');
$this->addForeignKey('fk_theme_category_files', '{{%theme_files}}', 'file_code', '{{%category_files}}', 'id', 'cascade', 'cascade');
}
public function safeDown()
{
$this->dropForeignKey('fk_theme_category_files', '{{%theme_files}}');
$this->dropForeignKey('fk_theme_files_theme', '{{%theme_files}}');
$this->dropForeignKey('fk_theme_category', '{{%theme}}');
......
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