lundi 1 août 2016

Baum nested set, how to get category in random order?

I'm using Baum nested set for category and sub-category in my application with Laravel 5.2 (The categories I use them as my menu), I want the menu to keep changing on page refresh and when user navigate to different pages.

Just wondering if there's a way I can fetch category using Baum Nested set in random order.

currently using:

Category::all()->toHierarchy()->get();

It works fine, but when I try

Category::inRandomOrder()->toHierarchy()->get();

doesn't work.

Anyone tried this before?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire