php - Laravel 4 - Eloquent. Infinite children into usable array? -
i've got categories table. each category can have optional parent (defaults 0 if no parent). what want build simple html list tree levels of categories. example date: foods -- fruit ---- apple ---- banana ---- orange -- veg ---- cucumber ---- lettuce drinks -- alcoholic ---- beer ---- vodka misc -- household objects ---- kitchen ------ electrical -------- cooking ---------- stove ---------- toaster ---------- microwave note needs work around 10 'levels'. i'd love infinite dont want going down route of using nested set model it'll cause huge delays on project. the docs on laravel terrible, no real reference start. i've been playing days trying work out , seem getting without huge messy block of each loops within each other 10 times. i've got tree of data using following in model: <?php class item extends eloquent { public function parent() { return $this->hasone('item', 'id', 'parent_id'); } ...