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


PHP Category::findAll方法代码示例

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


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

示例1: actionMap

 public function actionMap()
 {
     Yii::$app->response->format = Response::FORMAT_RAW;
     $headers = Yii::$app->response->headers;
     $headers->add('Content-Type', 'text/xml');
     $dom = new \DOMDocument("1.0", "utf-8");
     $root = $dom->createElement("urlset");
     $root->setAttribute("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9");
     $dom->appendChild($root);
     $categories = Category::findAll(['is_active' => 1]);
     $articles = Article::findAll(['is_active' => 1]);
     $items = array_merge($categories, $articles);
     foreach ($items as $item) {
         $url = $dom->createElement("url");
         $loc = $dom->createElement("loc");
         if ($item instanceof Article) {
             $loc->appendChild($dom->createTextNode(Url::to(['article/view', 'id' => $item->id], true)));
         } else {
             $loc->appendChild($dom->createTextNode(Url::to(['category/view', 'id' => $item->id], true)));
         }
         $lastmod = $dom->createElement("lastmod");
         $lastmod->appendChild($dom->createTextNode($item->timestamp));
         $changefreq = $dom->createElement("changefreq");
         $changefreq->appendChild($dom->createTextNode("monthly"));
         $priority = $dom->createElement("priority");
         $priority->appendChild($dom->createTextNode("0.5"));
         $url->appendChild($loc);
         $url->appendChild($lastmod);
         $url->appendChild($changefreq);
         $url->appendChild($priority);
         $root->appendChild($url);
     }
     return $dom->saveXML();
 }
开发者ID:amarchenkov,项目名称:myCMS,代码行数:34,代码来源:SiteController.php

示例2: actionIndex

 public function actionIndex()
 {
     $limit = 10;
     // Make Latest Ads
     $latestAds = Ad::find()->where(['status' => Ad::STATUS_ACTIVE])->orderBy(['id' => SORT_DESC])->limit($limit)->all();
     // Most Popular Ads
     $popularAds = Ad::find()->where(['status' => Ad::STATUS_ACTIVE])->orderBy(['view_count' => SORT_DESC])->limit($limit)->all();
     // Random Ads
     $randomAds = Ad::find()->where(['status' => Ad::STATUS_ACTIVE])->orderBy(['rand()' => SORT_DESC])->limit($limit)->all();
     return $this->render('index', ['categories' => Category::findAll(['status' => 1]), 'latestAds' => $latestAds, 'popularAds' => $popularAds, 'randomAds' => $randomAds]);
 }
开发者ID:shahid80,项目名称:EWay,代码行数:11,代码来源:SiteController.php

示例3: actionOrder

 public function actionOrder($id)
 {
     $this->layout = 'page';
     $model = new Order();
     $categories = Category::findAll(['status' => Category::STATUS_ENABLED]);
     $product = Product::find()->where(['id' => $id, 'status' => Product::STATUS_ENABLED])->limit(1)->one();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $order = new Order();
         $order->key = strtoupper(Yii::$app->security->generateRandomString(6));
         $order->name = $product->name;
         $order->thumbnail = $product->thumbnail;
         $order->price = $product->price;
         $order->count = $model->count;
         $order->email = $model->email;
         $order->message = $model->message;
         $order->date = time();
         $order->insert();
         Yii::$app->session->set('orderID', $order->id);
         return $this->redirect(['product/confirm']);
     } else {
         return $this->render('order', ['model' => $model, 'categories' => $categories, 'product' => $product]);
     }
 }
开发者ID:phucnv206,项目名称:thoitrang,代码行数:23,代码来源:ProductController.php

示例4: cmp

<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\widgets\Recursive;
use app\models\Category;
/* @var $this yii\web\View */
/* @var $model app\models\Skill */
/* @var $form yii\widgets\ActiveForm */
$cats = Category::findAll(['state' => 1]);
function cmp($a, $b)
{
    return strcmp($a->parents, $b->parents);
}
usort($cats, "cmp");
$data = Recursive::sortArrayDropDown($cats);
?>

<div class="row-fluid">
    <?php 
$form = ActiveForm::begin(['options' => ['class' => 'form-horizontal', 'enctype' => 'multipart/form-data']]);
?>

    <?php 
echo $form->field($model, 'title', ['template' => '{label}<div class="controls">{input}{error}{hint}</div>'])->textInput(['maxlength' => true, 'class' => 'span6', 'onblur' => 'fillAlias()']);
?>

    <?php 
echo $form->field($model, 'alias', ['template' => '{label}<div class="controls">{input}{error}{hint}</div>'])->textInput(['maxlength' => true, 'class' => 'span6']);
?>
开发者ID:ClarkLusm,项目名称:htdocs,代码行数:30,代码来源:_form.php

示例5:

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <div class="operation-form">

    <?php 
$form = ActiveForm::begin(['id' => 'operation-form', 'options' => ['class' => 'form-horizontal col-lg-5'], 'fieldConfig' => ['template' => "{label}\n<div class=\"col-lg-8\">{input}</div>\n<div class=\"col-lg-1\"></div><div class=\"col-lg-12\">{error}</div>", 'labelOptions' => ['class' => 'col-lg-4 control-label']]]);
?>
	
	<?php 
$currencies = Currency::find()->all();
$currency_items = ArrayHelper::map($currencies, 'id', 'iso');
$operation_type = $t === 'income' ? 0 : 1;
$categories = Category::findAll(['type' => $operation_type]);
$category_items = ArrayHelper::map($categories, 'id', 'name');
$category_label = $t === 'income' ? 'Статья доходов' : 'Статья расходов';
?>
	
	<?php 
echo $form->field($model, 'currency_id')->dropDownList($currency_items)->label('Валюта');
?>
	<?php 
echo $form->field($model, 'summ');
?>
	<?php 
echo $form->field($model, 'category_id')->dropDownList($category_items)->label($category_label);
?>
	<?php 
echo $form->field($model, 'description');
开发者ID:Nhassa,项目名称:budget,代码行数:31,代码来源:update.php

示例6: actionBulkDelete

 /**
  * Delete multiple existing Category model.
  * For ajax request will return json object
  * and for non-ajax request if deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionBulkDelete()
 {
     $request = Yii::$app->request;
     $pks = $request->post('pks');
     // Array or selected records primary keys
     foreach (Category::findAll(json_decode($pks)) as $model) {
         $model->delete();
     }
     if ($request->isAjax) {
         /*
          *   Process for ajax request
          */
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ['forceClose' => true, 'forceReload' => '#crud-datatable-pjax'];
     } else {
         /*
          *   Process for non-ajax request
          */
         return $this->redirect(['index']);
     }
 }
开发者ID:javierojeda94,项目名称:sas_final,代码行数:28,代码来源:CategoryController.php

示例7: actionLoadProducts

 public function actionLoadProducts()
 {
     $categories = Category::findAll(['status' => 'ACTIVE']);
     $return = [];
     foreach ($categories as $i => $category) {
         $cat = [];
         $cat['name'] = $category->name;
         foreach ($category->subcategories as $j => $subcategory) {
             $subcat = [];
             $subcat['name'] = $subcategory->name;
             foreach ($subcategory->products as $k => $product) {
                 $prod = [];
                 $prod['id'] = $product->id;
                 $prod['name'] = $product->name;
                 $prod['description'] = $product->description;
                 $prod['stock'] = $product->stock;
                 $prod['image1'] = $product->image1;
                 $prod['image2'] = $product->image2;
                 $prod['image3'] = $product->image3;
                 $prod['price'] = $product->price;
                 $subcat[$product->id] = $prod;
             }
             $cat[$subcategory->id] = $subcat;
         }
         $return[$category->id] = $cat;
     }
     return json_encode($return);
 }
开发者ID:frankpaul142,项目名称:mosaico,代码行数:28,代码来源:SiteController.php

示例8: actionDelete

 /**
  * Deletes an existing Category model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     if (Yii::$app->user->can("category/delete")) {
         $child = Category::findAll(['parent' => $id]);
         $products = Product::find()->where(['category_id' => $id])->all();
         for ($i = 0; $i < sizeof($products); $i++) {
             $products[$i]->category_id = NULL;
             $products[$i]->save();
         }
         for ($i = 0; $i < sizeof($child); $i++) {
             $products_child = Product::find()->where(['category_id' => $child[$i]->id])->all();
             for ($j = 0; $i < sizeof($products_child); $j++) {
                 $products_child[$j]->category_id = NULL;
                 $products_child[$j]->save();
             }
             $child[$i]->delete();
         }
         $this->findModel($id)->delete();
         return $this->redirect(['index']);
     } else {
         Yii::$app->session->setFlash('error', 'Нет доступа!');
         $this->redirect('/');
     }
 }
开发者ID:dosh93,项目名称:shop,代码行数:30,代码来源:CategoryController.php

示例9: beforeValidate

 /**
  * @inheritdoc
  */
 public function beforeValidate()
 {
     if (!parent::beforeValidate()) {
         return false;
     }
     if ($this->scenario == 'create' || $this->scenario == 'update') {
         $this->categoriesValid = Category::findAll($this->categories);
         $this->usersValid = User::findAll($this->users);
     }
     return true;
 }
开发者ID:nepster-web,项目名称:yii2-test-job,代码行数:14,代码来源:BookForm.php

示例10:

<?php

use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use app\assets\AppAsset;
use app\models\Product;
use app\models\Category;
use app\models\Subcategory;
/* @var $this \yii\web\View */
/* @var $content string */
AppAsset::register($this);
$categories = Category::findAll(['status' => 'ACTIVE']);
$subs = [];
foreach ($categories as $i => $category) {
    $subs[] = $category->subcategories[0]->id;
}
$this->beginPage();
?>
<!DOCTYPE html>
<html lang="<?php 
echo Yii::$app->language;
?>
">
<head>
    <meta charset="<?php 
echo Yii::$app->charset;
?>
"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
开发者ID:frankpaul142,项目名称:mosaico,代码行数:31,代码来源:layoutIndex.php


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