当前位置: 首页>>代码示例>>PHP>>正文


PHP Category::getKeyValuePairs方法代码示例

本文整理汇总了PHP中common\models\Category::getKeyValuePairs方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::getKeyValuePairs方法的具体用法?PHP Category::getKeyValuePairs怎么用?PHP Category::getKeyValuePairs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common\models\Category的用法示例。


在下文中一共展示了Category::getKeyValuePairs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionDetail

 public function actionDetail($id)
 {
     /* @var $model Store */
     $model = Store::findOne($id);
     if (!$model) {
         throw new BadRequestHttpException('未找到该营业点!');
     }
     if ($model->status === Store::STATUS_DISABLED) {
         throw new BadRequestHttpException('该店铺已被禁用,请重新选择!');
     }
     $data['store'] = $model->toArray(['id', 'name', 'school_id', 'address', 'cellphone', 'telephone', 'notice', 'status', 'hours', 'has_book', 'has_down', 'has_gift', 'has_least', 'down_upper', 'down_val', 'gift_upper', 'gift_val', 'least_val', 'created_at']);
     $data['store']['downMsg'] = $model->downMsg;
     $data['store']['giftMsg'] = $model->giftMsg;
     $data['categories'] = Category::getKeyValuePairs();
     foreach ($data['categories'] as $key => $name) {
         $goodsList = $model->getGoods($key)->all();
         if ($goodsList) {
             foreach ($goodsList as $goods) {
                 $goodsArr = $goods->toArray();
                 $data['goodsList'][$key][] = $goodsArr;
             }
         } else {
             $data['goodsList'][$key] = [];
         }
     }
     return $data;
 }
开发者ID:daixianceng,项目名称:xiaoego.com,代码行数:27,代码来源:StoreController.php

示例2: function

use common\models\Category;
use common\models\Store;
$this->title = '商品列表';
?>
<p>
    <?php 
echo Html::a('<i class="fa fa-plus"></i> 添加商品', ['goods/add'], ['class' => 'btn btn-primary']);
?>
</p>
<div class="row">
    <div class="col-lg-12">
        <?php 
Pjax::begin();
?>
        <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'tableOptions' => ['class' => 'table table-striped table-bordered table-center'], 'summaryOptions' => ['tag' => 'p', 'class' => 'text-right text-info'], 'columns' => [['class' => 'yii\\grid\\SerialColumn', 'headerOptions' => ['class' => '']], ['attribute' => 'name', 'headerOptions' => ['class' => 'col-md-2'], 'filterInputOptions' => ['class' => 'form-control input-sm']], ['attribute' => 'category_id', 'headerOptions' => ['class' => 'col-md-1'], 'filter' => Category::getKeyValuePairs(), 'filterInputOptions' => ['class' => 'form-control input-sm'], 'value' => function ($model, $key, $index, $column) {
    return $model->category->name;
}], ['attribute' => 'store_id', 'headerOptions' => ['class' => 'col-md-2'], 'filterInputOptions' => ['class' => 'form-control input-sm'], 'value' => function ($model, $key, $index, $column) {
    return $model->store->school->name . '-' . $model->store->name;
}, 'filter' => Select2::widget(['model' => $searchModel, 'initValueText' => ($store = Store::findOne($searchModel->store_id)) ? $store->name : '', 'attribute' => 'store_id', 'size' => Select2::SMALL, 'theme' => Select2::THEME_KRAJEE, 'options' => ['placeholder' => '搜索店铺名称...'], 'pluginOptions' => ['allowClear' => true, 'minimumInputLength' => 3, 'ajax' => ['url' => Url::to(['/store/name-filter']), 'dataType' => 'json', 'data' => new JsExpression('function(params) { return {q:params.term}; }')], 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), 'templateResult' => new JsExpression('function (store) { return store.text; }'), 'templateSelection' => new JsExpression('function (store) { return store.text; }')]])], ['attribute' => 'price', 'headerOptions' => ['class' => 'col-md-1'], 'format' => 'html', 'filterInputOptions' => ['class' => 'form-control input-sm', 'title' => '支持运算符'], 'value' => function ($model, $key, $index, $column) {
    return '&yen; ' . $model->price;
}], ['attribute' => 'surplus', 'headerOptions' => ['class' => 'col-md-1'], 'filterInputOptions' => ['class' => 'form-control input-sm', 'title' => '支持运算符']], ['attribute' => 'sales', 'headerOptions' => ['class' => 'col-md-1'], 'filterInputOptions' => ['class' => 'form-control input-sm', 'title' => '支持运算符']], ['attribute' => 'status', 'format' => 'raw', 'filter' => Goods::getStatusList(), 'filterInputOptions' => ['class' => 'form-control input-sm'], 'headerOptions' => ['class' => 'col-md-1'], 'value' => function ($model, $key, $index, $column) {
    return Html::dropDownList('status', $model->status, Goods::getStatusList(), ['data-id' => $model->id]);
}], ['attribute' => 'created_at', 'format' => ['date', 'php:Y-m-d H:i'], 'filter' => DatePicker::widget(['model' => $searchModel, 'type' => DatePicker::TYPE_COMPONENT_APPEND, 'attribute' => 'date', 'options' => ['class' => 'input-sm'], 'pluginOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd']]), 'headerOptions' => ['class' => 'col-md-2']], ['class' => 'yii\\grid\\ActionColumn', 'header' => '操作', 'headerOptions' => ['class' => 'col-md-1'], 'template' => '{update} {img} {surplus}', 'buttons' => ['img' => function ($url, $model, $key) {
    return Html::a('<span class="glyphicon glyphicon-picture" aria-hidden="true"></span>', $url, ['title' => '更新图片']);
}, 'surplus' => function ($url, $model, $key) {
    return Html::a('<span class="glyphicon glyphicon-equalizer" aria-hidden="true"></span>', $url, ['title' => '库存变化记录']);
}]]]]);
?>
        <?php 
Pjax::end();
开发者ID:daixianceng,项目名称:xiaoego.com,代码行数:31,代码来源:index.php

示例3:

$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>
        <div class="form-group">
            <label class="control-label">学校</label>
            <?php 
echo Html::dropDownList('school', $model->isNewRecord ? '' : $model->store->school_id, School::getKeyValuePairs(), ['class' => 'form-control']);
?>
        </div>
        <?php 
echo $form->field($model, 'store_id')->dropDownList($model->isNewRecord ? [] : Store::getKeyValuePairs($model->store->school_id));
?>
        <?php 
echo $form->field($model, 'name');
?>
        <?php 
echo $form->field($model, 'category_id')->widget(Select2::className(), ['data' => Category::getKeyValuePairs(), 'options' => ['placeholder' => '请选择分类'], 'pluginOptions' => ['allowClear' => true]]);
?>
        <?php 
if ($model->isNewRecord) {
    ?>
        <?php 
    echo $form->field($model, 'image')->widget(FileInput::className(), ['options' => ['accept' => 'image/*'], 'pluginOptions' => ['showUpload' => false, 'browseLabel' => '选择图片', 'removeLabel' => '删除']]);
    ?>
        <?php 
} else {
    ?>
        <?php 
    echo $form->field($model, 'image')->widget(FileInput::className(), ['options' => ['accept' => 'image/*'], 'pluginOptions' => ['showUpload' => false, 'browseLabel' => '选择图片', 'removeLabel' => '删除', 'initialPreview' => Html::img(Url::toCover($model->cover), ['class' => 'file-preview-image'])]]);
    ?>
        <?php 
}
开发者ID:daixianceng,项目名称:xiaoego.com,代码行数:31,代码来源:form.php


注:本文中的common\models\Category::getKeyValuePairs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。