Well. It’s been a long time since I’ve written a post. I was busy learning Laravel… Currently, I am trying the framework by working on a CMS, and, again, I have arrived at the phase of menus. And by “menus”, I am refering to multi-level menus. In the past I have found ways to bypass this dilemma, but now my time allowed me to dive into it.

First of all… If you put it inside MY_Model, you need to pass the get_menu() function properties and not variables. Also, why do you have NULL as value for root elements? Why not 0? More on this, you can find in my comments on your gist.