/** * Displays homepage. * * @return mixed */ public function actionIndex() { $model_product = new Product(); $model_manufacturer = new Manufacturer(); $home_slider_product = $model_product->find()->getHomeSliderProduct()->all(); $top_ten_products = $model_product->find()->getLatestTenProducts()->all(); $top_ten_manufacturer = $model_manufacturer->find()->where('status =:status', [':status' => 1])->limit(Custom::getCustomConfig()['max_allowed_manufacturer'])->all(); return $this->render('index', ['home_slider_product' => $home_slider_product, 'top_ten_products' => $top_ten_products, 'top_ten_manufacturer' => $top_ten_manufacturer]); }
<?php use yii\grid\GridView; use yii\data\ActiveDataProvider; use common\models\Manufacturer; /* @var $this yii\web\View */ $this->title = 'Manufacturers'; $this->params['breadcrumbs'][] = $this->title; $dataProvider = new ActiveDataProvider(['query' => Manufacturer::find(), 'pagination' => ['pageSize' => 20]]); ?> <div class="box"> <div class="box-body"> <?php if (Yii::$app->user->can('listResources')) { echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'name', ['attribute' => 'created_at', 'format' => ['datetime', 'php:Y-m-d H:i:s']], ['attribute' => 'updated_at', 'format' => ['datetime', 'php:Y-m-d H:i:s']], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update}']]]); } ?> </div> </div>
/** * Lists all Manufacturer models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => Manufacturer::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }
<?php echo Html::a($category->display_name, Url::to(['/category', 'id' => $category->id, 'name' => Html::encode($category->name)])); ?> </li> <?php } ?> </ul> </li> <li class="dropdown parent-menu"> <?php echo Html::a('Manufacturer', Url::to(['/manufacturer']), ['data-toggle' => 'dropdown', 'data-hover' => 'dropdown', 'class' => 'dropdown-toggle']); ?> <ul class="dropdown-menu list-group"> <?php $manufacturers = Manufacturer::find()->where('status = :s', [':s' => 1])->all(); foreach ($manufacturers as $manufacturer) { ?> <li class="list-group-item"> <?php echo Html::a($manufacturer->name, Url::to(['/manufacturer', 'id' => $manufacturer->id, 'name' => Html::encode($manufacturer->name)])); ?> </li> <?php } ?> </ul> </li> <li class="parent-menu"><?php echo Html::a('Shop', Url::to(['/shop'])); ?>
$this->params['breadcrumbs'][] = 'Edit'; ?> <div class="box"> <?php $form = ActiveForm::begin(['id' => 'edit-model-number-form', 'action' => 'save']); ?> <?php echo Html::activeHiddenInput($model, 'id'); ?> <div class="box-body"> <div class="form-group"> <?php echo $form->field($model, 'value'); ?> <?php echo $form->field($model, 'manufacturer_id')->dropDownList(ArrayHelper::map(Manufacturer::find()->orderBy('name')->all(), 'id', 'name'), ['disabled' => true]); ?> </div> <div class="box-footer"> <?php echo Button::widget(['label' => 'Save', 'options' => ['class' => 'btn btn-primary']]); ?> <?php echo Html::a('Cancel', Yii::$app->request->referrer, ['class' => 'btn btn-default']); ?> </div> </div> <?php ActiveForm::end(); ?> </div>
public function actionList() { echo Json::encode(array_map(function ($m) { return $m['name']; }, Manufacturer::find()->orderBy('name')->all())); }