public function actionIndex() { $query = Category::find(); $pagination = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]); $categories = $query->orderBy('name')->offset($pagination->offset)->limit($pagination->limit)->all(); return $this->render('index', ['categories' => $categories, 'pagination' => $pagination]); }
public static function test() { $category = Category::find()->one()->getNewses()->createCommand()->sql; //$news = $category->newses; echo '<pre>'; var_dump($category); }
/** * Creates a new Post model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Post(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model, 'category' => Category::find()->all(), 'authors' => User::find()->all()]); } }
public function actionViewbycat($cat) { $this->layout = "sidemenu"; $category = Category::find()->where(['category_name' => $cat])->one(); if (!$category) { throw new NotFoundHttpException('The requested page does not exist.'); } else { $product = Product::find()->where(['product_category' => $category->category_id])->all(); return $this->render('index', ['model' => $product]); } }
public function actionView($id) { $article = Articles::find()->where(['id' => $id])->one(); $article->view = $article->view + 1; $article->save(false); $popularArticle = Articles::find()->orderBy('view DESC')->limit(5)->all(); $discussedArticle = Articles::find()->joinWith('comments', true, 'RIGHT JOIN')->groupBy('comments.article_id')->orderBy('count(comments.article_id) DESC')->limit(5)->all(); $modelCategory = Category::find()->all(); $model = $this->findModel($id); $comments = Comments::find()->with('user')->where(['article_id' => $id, 'enable' => 1])->all(); $user = User::find()->where(['id' => $model->author_id])->one(); return $this->render('view', ['model' => $model, 'modelCategory' => $modelCategory, 'user' => $user, 'comments' => $comments, 'popularArticle' => $popularArticle, 'discussedArticle' => $discussedArticle]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Category::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Category::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } // grid filtering conditions $query->andFilterWhere(['id' => $this->id, 'pid' => $this->pid, 'sort' => $this->sort, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]); return $dataProvider; }
/** * Displays homepage. * * @return mixed */ public function actionIndex() { $modelCategory = Category::find()->all(); $modelArticle = Articles::find()->with('articleImg')->orderBy('id DESC')->all(); $popularArticle = Articles::find()->orderBy('view DESC')->limit(5)->all(); $discussedArticle = Articles::find()->joinWith('comments', true, 'RIGHT JOIN')->groupBy('comments.article_id')->orderBy('count(comments.article_id) DESC')->limit(5)->all(); $arrUser = array(); $userName = array(); foreach ($modelArticle as $article) { $arrUser[] = $article['author_id']; } foreach ($arrUser as $i => $user) { $userModel = User::find()->where(['id' => $user])->all(); $userName[] = $userModel[0]; } return $this->render('index', ['modelCategory' => $modelCategory, 'modelArticle' => $modelArticle, 'userName' => $userName, 'popularArticle' => $popularArticle, 'discussedArticle' => $discussedArticle]); }
public function actionSitemapIndex() { \Yii::$app->response->format = \yii\web\Response::FORMAT_RAW; \Yii::$app->response->headers->add('Content-Type', 'text/xml; charset=utf-8'); if (\Yii::$app->cache->exists('sitemapIndex')) { return \Yii::$app->cache->get('sitemapIndex'); } $generator = new SitemapGenerator(['namespaces' => ['xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9']]); $categories = $lastModified = []; foreach (News::find()->select(['categoryID', 'MAX(`publishDate`) as `date`'])->groupBy('categoryID')->asArray()->each() as $modified) { $lastModified[$modified['categoryID']] = $modified['date']; } foreach (Category::find()->where(['categories.deleted' => 0, 'categories.published' => 1])->joinWith('news', false)->groupBy('news.categoryID')->having('COUNT(`news`.`id`) >= 1')->each() as $category) { $lastmod = array_key_exists($category->id, $lastModified) ? $lastModified[$category->id] : 0; $categories[] = ['loc' => yii\helpers\Url::to(['site/sitemap-xml', 'id' => $category->id], true), 'lastmod' => gmdate('Y-m-d\\TH:i:s\\Z', $lastmod)]; } $content = $generator->createIndex($categories); \Yii::$app->cache->add('sitemapIndex', $content, 3600); return $content; }
<h2 class="header"><?php echo $this->title; ?> </h2> <div class="card-panel site-signup col l12"> <?php $form = ActiveForm::begin(['id' => 'login-form', 'fieldConfig' => ['template' => '{input}{label}{error}']]); ?> <?php echo $form->field($model, 'name', ['options' => ['class' => 'input-field col s12 m12 l6']]); ?> <?php echo $form->field($model, 'category_id', ['options' => ['class' => 'input-field col s12 m12 l6']])->dropDownList(ArrayHelper::map(Category::find()->all(), 'id', 'name'), ['prompt' => 'Kateqoriyanı seçin']); ?> <?php echo $form->field($model, 'email', ['options' => ['class' => 'input-field col s12 m12 l6']]); ?> <?php echo $form->field($model, 'phone', ['options' => ['class' => 'input-field col s12 m12 l6']]); ?> <?php echo $form->field($model, 'description', ['options' => ['class' => 'input-field col s12']])->textarea(['class' => 'materialize-textarea']); ?> <?php
echo Html::encode($this->title); ?> </title> <?php $this->head(); ?> </head> <body> <?php $this->beginBody(); ?> <div class="wrap"> <?php NavBar::begin(['brandLabel' => 'Anon Shop.com', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]); $dropDownItems = []; $items = Category::find()->all(); foreach ($items as $data) { $dropDownItems[] = ['label' => $data->category_name, 'labelTemplate' => '{<h1>hahaha</h1>}', 'url' => ['customer/viewbycat', 'cat' => $data->category_name]]; } $menuItems = [['label' => 'Home', 'url' => ['/customer/index']], ['label' => 'Category', 'items' => $dropDownItems]]; if (Yii::$app->user->isGuest) { $menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']]; $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']]; } else { $menuItems[] = ['label' => 'Profile', 'url' => ['/customer/profile']]; $menuItems[] = ['label' => 'Cart', 'url' => ['/customer/cart']]; $menuItems[] = ['label' => 'Logout (' . Yii::$app->user->identity->username . ')', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']]; } echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => $menuItems]); NavBar::end(); ?>
public function init() { $this->filter = Category::find()->all(); }
<li><a href="https://plus.google.com/" target="_blank"> <div class="social-btn z-depth-1"><i class="zmdi zmdi-google-plus"></i></div> </a></li> </ul> </div> </div> </footer> </div> <div class="category-sidenav overflow-hidden"> <div class="row"> <div class="head-close-block"> <i class="zmdi zmdi-hc-3x zmdi-close"></i> </div> <?php foreach (Category::find()->orderBy('id')->all() as $category) { ?> <div class="col l2 m3 s6"> <a href="/<?php echo $category->slug; ?> /"> <div class="category-card"> <img class="responsive-img z-depth-1" src="/uploads/categories/<?php echo $category->img; ?> "> <span class="category-card-icon"><i class="zmdi zmdi-hc-3x <?php echo $category->icon; ?> "></i></span>
/** * @param \frontend\models\Transaction $model * * @return string */ public static function getCategoryForBlockString(Transaction $model) { $result = []; $transaction2Categories = $model->transaction2Category; if (!empty($transaction2Categories)) { /** @var Transaction2Category $transaction2Category */ foreach ($transaction2Categories as $transaction2Category) { /** @var Category $category */ $category = Category::find()->andWhere(['id' => $transaction2Category->category_id])->one(); if (isset($category)) { $result[] = Html::a($category->title, Yii::$app->urlManager->createUrl(['transaction/category', 'id' => $category->id]), ['class' => 'tag tag-blue', 'data-pjax' => '0']); } } } return implode(' ', $result); }
/* @var $this yii\web\View */ /* @var $model frontend\models\Service */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="service-form"> <?php $form = ActiveForm::begin([]); ?> <div class="row"> <div class="col-md-6"> <?php echo $form->field($model, 'category_id')->widget(Select2::classname(), ['language' => 'ru', 'data' => ArrayHelper::map(Category::find()->all(), 'id', 'name'), 'options' => ['placeholder' => 'Выберите состояние ...'], 'pluginOptions' => ['allowClear' => true]]); ?> <?php echo $form->field($model, 'owner')->widget(Select2::classname(), ['language' => 'ru', 'data' => ArrayHelper::map(User::find()->all(), 'id', 'username'), 'options' => ['placeholder' => 'Выберите состояние ...'], 'pluginOptions' => ['allowClear' => true]]); ?> <?php echo $form->field($model, 'can_reserve')->widget(SwitchInput::classname(), []); ?> <?php echo $form->field($model, 'status')->widget(SwitchInput::classname(), []); ?> <?php echo $form->field($model, 'longlat')->textInput(['maxlength' => true]); ?> <?php
public static function getMenu($type) { return Category::find()->where(['menu' => $type])->orderBy('menu_position')->all(); }
<?php use frontend\models\Category; use frontend\models\Menu; use yii\helpers\Html; $firstRowCategories = Category::find()->where(['in', 'id', [33, 35, 38, 39]])->all(); $secondRowCategories = Category::find()->where(['in', 'id', [45, 46, 47, 48]])->all(); /** @var Category[] $firstRowCategories */ ?> <div id="gkBottomWrap" class="gkWrap clear"> <div id="gkMiddleNav1" class="gkWrap"> <ul class="menu"> <?php foreach (Menu::findByAlias('top-menu-1')->items as $menuItem) { echo Html::tag('li', Html::a($menuItem->name, $menuItem->link)); } ?> </ul> </div> <div id="gkBottom1" class="gkWrap"> <?php foreach ($firstRowCategories as $category) { ?> <div class="gkCol gkColRight"> <div class="box nsp blue color_title small"> <div> <h3 class="header"> <span><?php echo $category->title; ?>
?> <!--">Delete</a>--> </span> <span style="margin-left: 10px"> <a class="btn btn-default" style="background-color: #d0eded" href="<?php echo Yii::$app->urlManager->createUrl(['job/edit', 'id' => $job->id]); ?> ">Edit</a> </span> <?php } if (!empty($job)) { ?> <h3>From category: <?php $category = Category::find()->where(['id' => $job->category_id])->one(); echo $category->name; ?> </h3> <span style="font-size: 18px">Published: <?php echo Job::dateVacancy($job); ?> </span> <h2 class="well"><?php echo $job->title; ?> <span style="font-size: 24px; color: green"> Salary: <?php echo $job->salary; ?> </span></h2> <code style="font-size: 22px"><?php
</div> </div> <div class="box-content"> <div class="row"> <div class="items-form"> <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'cat_id')->dropDownList(ArrayHelper::map(Category::find()->all(), 'id', 'name'), ['prompt' => '-- Выберите--'])->label('Категирия. <a href="/category/create"> Создать</a>'); ?> <?php echo $form->field($model, 'brend_id')->dropDownList(ArrayHelper::map(Brend::find()->all(), 'id', 'name'), ['prompt' => '-- Выберите--'])->label('Производиетель звукоснимателя. <a href="/brend/create"> Создать</a>'); ?> <?php echo $form->field($model, 'strings')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'anker')->textInput(['maxlength' => true]); ?> <?php
public function actionIndex($slug) { $category = Category::find()->where(['slug' => $slug])->one(); return $this->render('index', ['category' => $category]); }
<?php echo Html::label('Max Price', '', ['id' => 'min-price']); ?> <?php echo Html::input('number', 'maxprice', '', ['id' => 'max-input', 'autocomplete' => 'off', 'class' => 'form-control', 'required' => '', 'type' => 'number', 'step' => '1000', 'min' => '1000', 'max' => '1000000000']); ?> </div> <div class="form-group"> <?php echo Html::label('Category', '', ['id' => 'min-price']); ?> <?php echo Html::dropDownList('category', '', ArrayHelper::map(Category::find()->all(), 'category_id', 'category_name'), ['class' => 'form-control']); ?> </div> <?php echo Html::submitButton('Search Product', ['class' => 'btn btn-primary']); ?> <?php echo Html::endForm();
<?php echo $form->field($model, 'description')->textarea(['rows' => 6]); ?> <?php echo $form->field($model, 'file')->fileInput(); ?> <!-- --><?php //= $form->field($model, 'image')->textInput(['maxlength' => true]) //= $form->field($model, 'tags')->checkboxList( // ArrayHelper::map($tags, 'id', 'title') //); ?> <?php echo $form->field($model, 'category_id')->label('Category')->dropDownList(Category::find()->select(['name', 'id'])->with('posts')->indexBy('id')->column(), ['prompt' => 'List of categories'])->hint('Choose the author'); ?> <?php echo $form->field($model, 'author_id')->label('Author')->dropDownList(Author::find()->select(['name', 'id'])->with('posts')->indexBy('id')->column(), ['prompt' => 'List of authors'])->hint('Choose the author'); ?> <!-- --><?php //= $form->field($model, 'tags')->textInput(['maxlength' => true]) ?> <!-- --><?php // // echo "<pre>"; // print_r($model->listTags); // echo "</pre>"; // die(); //
$this->params['breadcrumbs'][] = $this->title; ?> <div class="job-edit"> <h1 class="page-header">Edit Job</h1> <?php $form = ActiveForm::begin(); /* * hide errors in production */ ?> <?php echo $form->errorSummary($job); ?> <?php echo $form->field($job, 'category_id')->dropDownList(Category::find()->select(['name', 'id'])->indexBy('id')->column(), ['prompt' => 'Select Category']); ?> <?php echo $form->field($job, 'title'); ?> <?php echo $form->field($job, 'description')->textarea(['rows' => 4]); ?> <?php echo $form->field($job, 'type')->dropDownList(['full_time' => 'Full-Time', 'part_time' => 'Part-Time', 'as_needed' => 'As Needed'], ['prompt' => 'Select job-type']); ?> <?php echo $form->field($job, 'reqierement'); ?> <?php echo $form->field($job, 'salary')->dropDownList(['$20-40k' => '$20 - 40k', '$40-60k' => '$40 - 60k', '$60-80k' => '$60 - 80k', '$80-100k' => '$80 - 100k', 'over' => 'Over $100k', 'blank' => 'No chosen'], ['prompt' => 'Choose salary range']);
public function getCategory() { return Category::find()->where(['id' => $this->category_id])->one(); }
public function actionCatalogDetail() { $modelSocial = Social::findOne(1); $modelCategiry = Category::find()->limit(4)->asArray()->all(); $item_id = Yii::$app->request->get('item'); $itemsModel = Items::findOne($item_id); $cat = $itemsModel->cat_id; $photosModel = Photo::getPhotos($item_id, 5); return $this->render('catalog-detail', ['itemsModel' => $itemsModel, 'modelCategiry' => $modelCategiry, 'cat' => $cat, 'photosModel' => $photosModel, 'modelSocial' => $modelSocial]); }
protected function renderIndex() { $modelAll = Category::find()->orderBy('position')->all(); return $this->render('index', ['modelAll' => $modelAll]); }
/** * Lists all Category models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => Category::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }