what you need is a recursive function, basically a function that calls itself as soon as a child contains an submenu
example: http://www.lornajane.net/posts/2012/php-recursive-function-example-factorial-numbers
maybe instead of writing this yourself you can use Baum (https://github.com/etrepat/baum)
Thanks for responding, what would the recursive function look like? Do you have some sort of example?
It would look like the one you posted above. It works but is not very efficient, so either you cache it or you use a workaround such as Nested Sets (see the Baum package above) or Closure Table.
zenry said:
what you need is a recursive function, basically a function that calls itself as soon as a child contains an submenu
example: http://www.lornajane.net/posts/2012/php-recursive-function-example-factorial-numbers
His example is already recursive, it is calling the same function inside (self::createSubmenu).
barryvdh said:
zenry said:
what you need is a recursive function, basically a function that calls itself as soon as a child contains an submenu
example: http://www.lornajane.net/posts/2012/php-recursive-function-example-factorial-numbers
His example is already recursive, it is calling the same function inside (self::createSubmenu).
ah yes, quite right mr Barry, her example is already a recursive function
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community