Commit b2318ab4 by dianc

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

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