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


PHP Category::roots方法代码示例

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


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

示例1: create

 public function create()
 {
     $pid = intval(Input::get('id', 0));
     if ($pid != 0) {
         $category = Category::findOrFail($pid);
     } else {
         $category = false;
     }
     $roots = Category::roots()->get();
     return view('admin.pages.category.add', compact('category', 'roots', 'pid'));
 }
开发者ID:blozixdextr,项目名称:tuasist2,代码行数:11,代码来源:CategoryController.php

示例2: create

 public function create($category = 0)
 {
     $category = intval($category);
     if ($category > 0) {
         $category = Category::findOrFail($category);
     }
     $categories = Category::roots()->get();
     $user = Auth::user();
     $states = Location::states()->first();
     $regions = $states->children()->first();
     $locations = $regions->children;
     return view('pages.task.create', compact('category', 'categories', 'user', 'locations'));
 }
开发者ID:blozixdextr,项目名称:tuasist2,代码行数:13,代码来源:TaskController.php

示例3: getFilters

 public function getFilters($slug)
 {
     $currentCat = Category::findBySlug($slug);
     if (!$currentCat) {
         $currentCat = Category::findBySlug("shop");
     }
     $filters = ["id" => $currentCat->id, "category" => "Categories", "child" => $currentCat->getDescendants(1, ['id', 'category'])->toHierarchy()];
     $cats = Category::roots()->where("url_key", "!=", 'shop')->where("url_key", "!=", "popular")->get()->toHierarchy();
     foreach ($cats as $cat) {
         $cat->child = $cat->getDescendants(1, ['id', 'category'])->toHierarchy();
     }
     $cats = $cats->toArray();
     array_unshift($cats, $filters);
     return response()->json($cats);
 }
开发者ID:bhavs123,项目名称:web,代码行数:15,代码来源:CategoryController.php

示例4: getFill

 public function getFill()
 {
     if (!$this->checkProfileType()) {
         return redirect('/profile');
     }
     if ($this->checkProfileFill()) {
         return redirect('/profile');
     }
     $user = $this->user;
     $profile = $this->user->profile;
     $city = $profile->city;
     if ($city) {
         $region = $city->parent;
     } else {
         $region = Location::states()->first()->children()->first();
     }
     $cities = $region->children;
     $categories = Category::roots()->get();
     $subscribePeriods = ['asap', 'hour', 'twice-day', 'day', 'two-days'];
     return view('pages.profile.fill', compact('user', 'profile', 'cities', 'categories', 'subscribePeriods'));
 }
开发者ID:blozixdextr,项目名称:tuasist2,代码行数:21,代码来源:ProfileController.php

示例5: subCategory

 public function subCategory(Request $request, $category, $format = '')
 {
     if ($format == '' && $request->ajax()) {
         $format = 'json';
     }
     $category = intval($category);
     if ($category == 0) {
         $categories = Category::roots()->get();
     } else {
         $category = Category::findOrFail($category);
         $categories = $category->children;
     }
     $categoriesTranslated = [];
     foreach ($categories as $c) {
         $t = ['title' => trans('categories.' . $c['title'] . '.title'), 'url' => trans('categories.' . $c['title'] . '.url'), 'id' => $c->id, 'pid' => $c->pid];
         $categoriesTranslated[] = $t;
     }
     if ($format = 'json') {
         return $categoriesTranslated;
     }
 }
开发者ID:blozixdextr,项目名称:tuasist2,代码行数:21,代码来源:CategoryController.php

示例6: Category

<div class="category-index">

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

    <p>
        <?php 
echo Html::a(Yii::t('app', 'Create Category'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
$category = new Category();
$roots = $category->roots()->all();
foreach ($roots as $key => $root) {
    $categories = Category::find()->where(['root' => $root->id])->orderBy('lft')->all();
    $level = 0;
    foreach ($categories as $n => $category) {
        if ($category->level == $level) {
            echo Html::endTag('li') . "\n";
        } elseif ($category->level > $level) {
            echo Html::beginTag('ul') . "\n";
        } else {
            echo Html::endTag('li') . "\n";
            for ($i = $level - $category->level; $i; $i--) {
                echo Html::endTag('ul') . "\n";
                echo Html::endTag('li') . "\n";
            }
        }
开发者ID:rocketyang,项目名称:dcms2,代码行数:31,代码来源:tree.php

示例7: Category

<?php

use yii\helpers\Html;
use yii\helpers\ArrayHelper;
use yii\bootstrap\ActiveForm;
use app\models\Category;
/**
 * @var yii\web\View $this
 * @var app\models\Category $model
 * @var yii\widgets\ActiveForm $form
 */
$category = new Category();
$Categories = $category->roots()->all();
$level = 0;
$items[0] = Yii::t('app', 'Please select the parent node');
foreach ($Categories as $key => $value) {
    $items[$value->attributes['id']] = $value->attributes['name'];
    $children = $value->descendants()->all();
    foreach ($children as $child) {
        $string = '  ';
        $string .= str_repeat('│  ', $child->level - $level - 1);
        if ($child->isLeaf() && !$child->next()->one()) {
            $string .= '└';
        } else {
            $string .= '├';
        }
        $string .= '─' . $child->name;
        $items[$child->id] = $string;
    }
}
if (!$model->isNewRecord) {
开发者ID:rocketyang,项目名称:dcms2,代码行数:31,代码来源:_form.php


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