Giter VIP home page Giter VIP logo

Comments (5)

lazychaser avatar lazychaser commented on June 18, 2024

Hi. Thats because youre loading children each time in a loop by invoking
relation method children() rather than using filled value. Change
children()->get() to children

from laravel-nestedset.

pogachar avatar pogachar commented on June 18, 2024

Thanks for a quick reply.

This only returns an empty collection on page with children.

from laravel-nestedset.

lazychaser avatar lazychaser commented on June 18, 2024

Get descendands of the page (this includes children and children of children, etc) and convert results to a tree:

$pages = $page->getDescendands()->toTree();
@unless($page->children->isEmpty())
  @foreach ($page->children as $child)
  @endforeach
@endunless

from laravel-nestedset.

pogachar avatar pogachar commented on June 18, 2024

Sorry but I just can't get this to work properly...

public function index(Page $page) //all pages
{
    $pages = $page->getDescendants()->linkNodes();
    return view('admin.pages.index', compact('pages'));
}

throws ErrorException in QueryBuilder.php line 150: Undefined offset: 0

I also get this warning from time to time

Maximum function nesting level of '100' reached, aborting!

from laravel-nestedset.

lazychaser avatar lazychaser commented on June 18, 2024

Sorry, man, I can't do it for you! You have a huge whitespace in understanding how both laravel and nestedsets work, please refer to the docs.

But, anyway, error in query builder just indicates that $page doesn't exists.

from laravel-nestedset.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.