public static function FetchDistrict() { $sql = 'SELECT DISTINCT district FROM app_customers_items '; $countries = Item::findBySql($sql)->all(); $listData = ArrayHelper::map($countries, 'district', 'district'); return $listData; }
public function getPhotos() { if (!$this->_photos) { $this->_photos = []; foreach (Photo::find()->where(['class' => Item::className(), 'item_id' => $this->id])->sort()->all() as $model) { $this->_photos[] = new PhotoObject($model); } } return $this->_photos; }
public function items($options = []) { if (!$this->_items) { $this->_items = []; $query = Item::find()->with('seo')->where(['category_id' => $this->id])->status(Item::STATUS_ON); if (!empty($options['where'])) { $query->andFilterWhere($options['where']); } if (!empty($options['orderBy'])) { $query->orderBy($options['orderBy']); } else { $query->sortDate(); } if (!empty($options['filters'])) { $query = Catalog::applyFilters($options['filters'], $query); } $this->_adp = new ActiveDataProvider(['query' => $query, 'pagination' => !empty($options['pagination']) ? $options['pagination'] : []]); foreach ($this->_adp->models as $model) { $this->_items[] = new ItemObject($model); } } return $this->_items; }
private function findItem($id_slug) { if (!($item = Item::find()->where(['or', 'item_id=:id_slug', 'slug=:id_slug'], [':id_slug' => $id_slug])->status(Item::STATUS_ON)->one())) { return null; } return new ItemObject($item); }
public function actionDeleteData() { $data = CustomerItems::deleteAll(); $data = Item::deleteAll("category_id=1"); $this->flash('success', Yii::t('easyii/customers', 'Data hase been removed successfully')); return $this->redirect(['/admin/customers/items/1']); }
<?php use app\modules\customers\models\Item; use yii\helpers\Html; use yii\helpers\Url; $this->title = Yii::t('easyii/customers', 'Catalog'); $module = $this->context->module->id; echo $this->render('_menu', ['category' => $model]); //echo count($model->items).'ddd'; die; $items = Item::find()->limit(50)->offset(10)->all(); ?> <?php if (count($items)) { ?> <table class="table table-hover"> <thead> <tr> <?php if (IS_ROOT) { ?> <th width="50">#</th> <?php } ?> <th><?php echo Yii::t('easyii', 'Name'); ?> </th> <th width="100"><?php echo Yii::t('easyii', 'Status');