當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。