Commit b2318ab4 by dianc

Merge remote-tracking branch 'origin/development' into development

parents 05f96e6f a761a5b2
...@@ -2,20 +2,20 @@ ...@@ -2,20 +2,20 @@
namespace backend\controllers; namespace backend\controllers;
use common\models\Theme;
use Yii; use Yii;
use common\models\website; use common\models\Website;
use backend\models\search\WebsiteSearch; use backend\models\search\WebsiteSearch;
use yii\web\Controller; use yii\web\Controller;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\helpers\ArrayHelper;
/** /**
* WebsiteController implements the CRUD actions for website model. * WebsiteController implements the CRUD actions for website model.
*/ */
class WebsiteController extends Controller class WebsiteController extends Controller
{ {
public function behaviors() public function behaviors()
{ {
return [ return [
...@@ -36,10 +36,12 @@ class WebsiteController extends Controller ...@@ -36,10 +36,12 @@ class WebsiteController extends Controller
{ {
$searchModel = new WebsiteSearch(); $searchModel = new WebsiteSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$themes = ArrayHelper::map(Theme::find()->all(), 'id', 'name');
return $this->render('index', [ return $this->render('index', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
'themes' => $themes,
]); ]);
} }
...@@ -62,18 +64,21 @@ class WebsiteController extends Controller ...@@ -62,18 +64,21 @@ class WebsiteController extends Controller
*/ */
public function actionCreate() public function actionCreate()
{ {
$model = new website(); $model = new Website();
$searchModel = new WebsiteSearch(); $searchModel = new WebsiteSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$themes = ArrayHelper::map(Theme::find()->all(), 'id', 'name');
if ($model->load(Yii::$app->request->post()) && $model->save()) { if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect('index', [ return $this->render('index', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
'themes' => $themes,
]); ]);
} else { } else {
return $this->render('create', [ return $this->render('create', [
'model' => $model, 'model' => $model,
'themes' => $themes,
]); ]);
} }
} }
...@@ -87,12 +92,20 @@ class WebsiteController extends Controller ...@@ -87,12 +92,20 @@ class WebsiteController extends Controller
public function actionUpdate($id) public function actionUpdate($id)
{ {
$model = $this->findModel($id); $model = $this->findModel($id);
$searchModel = new WebsiteSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$themes = ArrayHelper::map(Theme::find()->all(), 'id', 'name');
if ($model->load(Yii::$app->request->post()) && $model->save()) { if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]); return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'themes' => $themes,
]);
} else { } else {
return $this->render('update', [ return $this->render('update', [
'model' => $model, 'model' => $model,
'themes' => $themes,
]); ]);
} }
} }
...@@ -119,7 +132,7 @@ class WebsiteController extends Controller ...@@ -119,7 +132,7 @@ class WebsiteController extends Controller
*/ */
protected function findModel($id) protected function findModel($id)
{ {
if (($model = website::findOne($id)) !== null) { if (($model = Website::findOne($id)) !== null) {
return $model; return $model;
} else { } else {
throw new NotFoundHttpException('The requested page does not exist.'); throw new NotFoundHttpException('The requested page does not exist.');
......
...@@ -6,6 +6,7 @@ use yii\bootstrap\ActiveForm; ...@@ -6,6 +6,7 @@ use yii\bootstrap\ActiveForm;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model common\models\website */ /* @var $model common\models\website */
/* @var $form yii\bootstrap\ActiveForm */ /* @var $form yii\bootstrap\ActiveForm */
/* @var $themes array */
?> ?>
<div class="website-form"> <div class="website-form">
...@@ -24,7 +25,7 @@ use yii\bootstrap\ActiveForm; ...@@ -24,7 +25,7 @@ use yii\bootstrap\ActiveForm;
<div class="row"> <div class="row">
<div class="col-md-4"> <div class="col-md-4">
<?= $form->field($model, 'theme_id')->textInput() ?> <?= $form->field($model, 'theme_id')->dropDownList($themes,['prompt' => ' ']) ?>
</div> </div>
</div> </div>
......
...@@ -5,6 +5,8 @@ use yii\helpers\Html; ...@@ -5,6 +5,8 @@ use yii\helpers\Html;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model common\models\website */ /* @var $model common\models\website */
/* @var $themes array */
$this->title = Yii::t('backend', 'Create {modelClass}', [ $this->title = Yii::t('backend', 'Create {modelClass}', [
'modelClass' => 'Website', 'modelClass' => 'Website',
...@@ -16,6 +18,7 @@ $this->params['breadcrumbs'][] = $this->title; ...@@ -16,6 +18,7 @@ $this->params['breadcrumbs'][] = $this->title;
<?= $this->render('_form', [ <?= $this->render('_form', [
'model' => $model, 'model' => $model,
'themes' => $themes,
]) ?> ]) ?>
</div> </div>
...@@ -6,6 +6,7 @@ use yii\grid\GridView; ...@@ -6,6 +6,7 @@ use yii\grid\GridView;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $searchModel backend\models\search\WebsiteSearch */ /* @var $searchModel backend\models\search\WebsiteSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */ /* @var $dataProvider yii\data\ActiveDataProvider */
/* @var $themes array */
$this->title = Yii::t('backend', 'Websites'); $this->title = Yii::t('backend', 'Websites');
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
...@@ -17,7 +18,7 @@ $this->params['breadcrumbs'][] = $this->title; ...@@ -17,7 +18,7 @@ $this->params['breadcrumbs'][] = $this->title;
<p> <p>
<?= Html::a(Yii::t('backend', 'Create {modelClass}', [ <?= Html::a(Yii::t('backend', 'Create {modelClass}', [
'modelClass' => 'Website', 'modelClass' => 'Website',
]), ['create'], ['class' => 'btn btn-success']) ?> ]), ['create'], ['class' => 'btn btn-success']) ?>
</p> </p>
<?= GridView::widget([ <?= GridView::widget([
...@@ -28,12 +29,19 @@ $this->params['breadcrumbs'][] = $this->title; ...@@ -28,12 +29,19 @@ $this->params['breadcrumbs'][] = $this->title;
//'id', //'id',
'business_id', 'business_id',
'theme_id', [
'attribute' => 'theme_id',
'value' => function ($model) {
return $model->theme->name;
},
'filter' => Html::activeDropDownList($searchModel, 'theme_id',
$themes, ['class' => 'form-control', 'prompt' => ' ']),
],
'domain_name', 'domain_name',
[ [
'class'=>\common\grid\EnumColumn::className(), 'class' => \common\grid\EnumColumn::className(),
'attribute'=>'status', 'attribute' => 'status',
'enum'=>[ 'enum' => [
Yii::t('backend', 'In Active'), Yii::t('backend', 'In Active'),
Yii::t('backend', 'Active') Yii::t('backend', 'Active')
], ],
...@@ -42,8 +50,10 @@ $this->params['breadcrumbs'][] = $this->title; ...@@ -42,8 +50,10 @@ $this->params['breadcrumbs'][] = $this->title;
// 'created_at', // 'created_at',
// 'updated_at', // 'updated_at',
['class' => 'yii\grid\ActionColumn', [
'template' => '{update}{delete}'], 'class' => 'yii\grid\ActionColumn',
'template' => '{update}{delete}'
],
], ],
]); ?> ]); ?>
......
...@@ -4,6 +4,7 @@ use yii\helpers\Html; ...@@ -4,6 +4,7 @@ use yii\helpers\Html;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model common\models\website */ /* @var $model common\models\website */
/* @var $themes array */
$this->title = Yii::t('backend', 'Update {modelClass}: ', [ $this->title = Yii::t('backend', 'Update {modelClass}: ', [
'modelClass' => 'Website', 'modelClass' => 'Website',
...@@ -16,6 +17,7 @@ $this->params['breadcrumbs'][] = Yii::t('backend', 'Update'); ...@@ -16,6 +17,7 @@ $this->params['breadcrumbs'][] = Yii::t('backend', 'Update');
<?= $this->render('_form', [ <?= $this->render('_form', [
'model' => $model, 'model' => $model,
'themes' => $themes,
]) ?> ]) ?>
</div> </div>
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