예제 #1
0
 /**
  * Updates an existing ShopCategory model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $categories = ShopCategory::find()->all();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'categories' => $categories]);
     }
 }
예제 #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ShopCategory::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'parent_id' => $this->parent_id]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'slug', $this->slug]);
     return $dataProvider;
 }
예제 #3
0
파일: index.php 프로젝트: buuug7/game4039
use common\models\ShopProduct;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\search\ShopProductSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('common', 'Shop Product');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="shop-product-index">

	<?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

	<p>
		<?php 
echo Html::a(Yii::t('backend', 'Create {modelClass}', ['modelClass' => Yii::t('common', 'Shop Product')]), ['create'], ['class' => 'btn btn-success']);
?>
	</p>

	<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'title', ['attribute' => 'relation_game', 'value' => function ($model) {
    return $model->relationGame ? $model->relationGame->name : null;
}], 'description:ntext', ['attribute' => 'category_id', 'value' => function ($model) {
    return $model->category ? $model->category->title : null;
}, 'filter' => \yii\helpers\ArrayHelper::map(\common\models\ShopCategory::find()->all(), 'id', 'title')], 'price', ['label' => Yii::t('common', 'Thumbnail'), 'format' => 'html', 'value' => function ($dataProvider) {
    return Html::img(Yii::$app->glide->createSignedUrl(['glide/index', 'path' => $dataProvider->thumbnail_path, 'w' => 100], true), ['class' => 'img-rounded pull-left img-responsive']);
}], ['class' => \common\grid\EnumColumn::className(), 'attribute' => 'is_on_sale', 'enum' => [Yii::t('common', 'Not'), Yii::t('common', 'Yes')]], ['class' => \common\grid\EnumColumn::className(), 'attribute' => 'status', 'enum' => ShopProduct::getStatus()], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
예제 #4
0
<div class="panel-group" id="accordion-v2">
	<div class="panel panel-default">
		<div class="panel-heading">
			<h2 class="panel-title">
				<a data-toggle="collapse" data-parent="#accordion-v2" href="#collapseTwo">
					按照分类
					<i class="fa fa-angle-down"></i>
				</a>
			</h2>
		</div>
		<div id="collapseTwo" class="panel-collapse collapse in">
			<div class="panel-body">
				<ul class="list-unstyled checkbox-list">
					<?php 
foreach (ShopCategory::find()->all() as $sc) {
    ?>
						<li>
							<label class="checkbox">
								<input type="checkbox" name="checkbox" checked="">
								<i></i>
								<?php 
    echo Html::a($sc->title, ['list', 'ShopProductSearch[category_id]' => $sc->id]);
    ?>
								<small><?php 
    echo Buuug7Util::getOnSaleProductCount($sc->id);
    ?>
</small>
							</label>
						</li>