zoukankan      html  css  js  c++  java
  • 无限分类笔记

    1、查询所有有子节点的分类

    Category::hasChildren()->get();


    2、查询有子节点 但不是根分类的

    Category::hasChildren()->withoutRoot()->get();


    3、查询某个节点 所有的后代

    Category::hasChildren()->withoutRoot()->first()->descendants;


    descendants包含了所有的子节点 查询子节点的子节点

    4、如果只想查看子节点  可以使用 children

    Category::hasChildren()->withoutRoot()->first()->children;


    5、利用深度查询
    根节点深度为1 之后每一层以此类推

    Category::withDepth()->having('depth','=',2)->get();


    6、将某个节点调整顺序

    $node=Category::find(8);
    $node=$node->up();


    对查询的结果进行排序

    Category::withDepth()->having('depth','=',2)->defaultOrder()->get();












  • 相关阅读:
    HDU
    POJ
    POJ
    POJ
    POJ
    POJ
    POJ
    SPFA算法——最短路径
    POJ1251 Jungle Roads Kruskal+scanf输入小技巧
    MongoDB--关于数据库及选择MongoDB的原因
  • 原文地址:https://www.cnblogs.com/linzenews/p/12810212.html
Copyright © 2011-2022 走看看