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


PHP Category::get方法代码示例

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


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

示例1: actionIndex

 /**
  * Lists all Category models.
  * @return mixed
  */
 public function actionIndex()
 {
     //if(!Yii::$app->user->can('viewYourAuth')) throw new ForbiddenHttpException(Yii::t('app', 'No Auth'));
     $searchModel = new CategorySearch();
     $dataProvider = Category::get(0, Category::find()->asArray()->all());
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
开发者ID:James88,项目名称:www.yubin.com,代码行数:11,代码来源:CategoryController.php

示例2:

use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\News */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="news-form">

    <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>

    <?php 
echo $form->field($model, 'category_id')->dropDownList(ArrayHelper::map(Category::get(0, Category::find()->asArray()->all()), 'id', 'label'));
?>

    <?php 
echo $form->field($model, 'title')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'imageFile')->fileInput();
?>

    <?php 
//$form->field($model, 'keyword')->textInput(['maxlength' => true])
?>

    <?php 
开发者ID:pear2007,项目名称:www.yii2.com,代码行数:31,代码来源:_form.php

示例3: function

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

    <p>
        <?php 
echo Html::a(Yii::t('app', 'Create ') . Yii::t('app', 'Product'), ['create'], ['class' => 'btn btn-success']);
?>
        <?php 
echo Html::a(Yii::t('app', 'Batch ') . Yii::t('app', 'Delete'), '#', ['class' => 'btn btn-danger', 'id' => 'batchDelete']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\CheckboxColumn'], 'id', ['attribute' => 'category_id', 'value' => function ($model) {
    return $model->category->name;
}, 'filter' => Html::activeDropDownList($searchModel, 'category_id', ArrayHelper::map(Category::get(0, Category::find()->asArray()->all()), 'id', 'label'), ['class' => 'form-control', 'prompt' => Yii::t('app', 'Please Filter')])], 'name', 'sku', 'stock', 'market_price', 'price', ['attribute' => 'type', 'format' => 'html', 'value' => function ($model) {
    return \common\models\ProductType::labels($model->type);
}], ['attribute' => 'brand_id', 'value' => function ($model) {
    return $model->brand ? $model->brand->name : '-';
}, 'filter' => Html::activeDropDownList($searchModel, 'type', ArrayHelper::map(\common\models\Brand::find()->all(), 'id', 'name'), ['class' => 'form-control', 'prompt' => Yii::t('app', 'Please Filter')])], ['attribute' => 'status', 'format' => 'html', 'value' => function ($model) {
    if ($model->status === Status::STATUS_ACTIVE) {
        $class = 'label-success';
    } elseif ($model->status === Status::STATUS_INACTIVE) {
        $class = 'label-warning';
    } else {
        $class = 'label-danger';
    }
    return '<span class="label ' . $class . '">' . Status::labels($model->status) . '</span>';
}, 'filter' => Html::activeDropDownList($searchModel, 'status', Status::labels(), ['class' => 'form-control', 'prompt' => Yii::t('app', 'PROMPT_STATUS')])], 'created_at:date', ['class' => 'yii\\grid\\ActionColumn']]]);
?>
开发者ID:liangdabiao,项目名称:funshop,代码行数:30,代码来源:index.php

示例4:

<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use common\models\Category;
/* @var $this yii\web\View */
/* @var $model common\models\Category */
/* @var $form yii\widgets\ActiveForm */
$parentCategory = ArrayHelper::merge([0 => Yii::t('blog', 'Root Catalog')], ArrayHelper::map(Category::get(0, Category::find()->asArray()->all()), 'id', 'label'));
unset($parentCategory[$model->id]);
?>

<div class="category-form">

    <?php 
$form = ActiveForm::begin(['id' => 'mend-form', 'options' => ['class' => 'form-horizontal'], 'fieldConfig' => ['template' => "{label}\n<div class=\"col-lg-3\">{input}{hint}</div>\n<div class=\"col-lg-5\">{error}</div>", 'labelOptions' => ['class' => 'col-lg-2 control-label']]]);
?>

    <?php 
echo $form->field($model, 'parent_id')->dropDownList($parentCategory);
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => 128]);
?>

    <?php 
echo $form->field($model, 'brief')->textInput(['maxlength' => 255]);
?>
开发者ID:CTaiDeng,项目名称:funshop,代码行数:30,代码来源:_form.php

示例5:

<?php

use frontend\components\Nav;
$query = new \yii\db\Query();
$result = $query->select('sum(number) as number')->from('cart')->where(['or', 'session_id = "' . Yii::$app->session->id . '"', 'user_id = ' . (Yii::$app->user->id ? Yii::$app->user->id : -1)])->createCommand()->queryOne();
$totalNumber = $result['number'];
?>
<div class="hd_nav">
    <div class="hd_nav_bd cle">
        <div class="main_nav" id="main_nav">
            <div class="main_nav_link">
                <a href="javascript:;">全部商品分类</a>
            </div>
            <div class="main_cata" id="J_mainCata">
                <?php 
$allCategory = \common\models\Category::get(0, \common\models\Category::find()->asArray()->all());
foreach ($allCategory as $category) {
    if ($category["parent_id"] == 0) {
        $menuItems[$category['id']] = ['label' => $category['name'], 'url' => ['/category/view', 'id' => $category['id']]];
    } else {
        $menuItems[$category['parent_id']]['items'][$category['id']] = ['label' => $category['name'], 'url' => ['/category/view', 'id' => $category['id']]];
    }
}
echo Nav::widget(['options' => ['class' => ''], 'items' => $menuItems]);
?>

            </div>
            <div class="J_subCata" id="J_subCata">
            </div>
        </div>
        <ul class="sub_nav cle" id="sub_nav">
开发者ID:CTaiDeng,项目名称:funshop,代码行数:31,代码来源:headerNav.php


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