vendredi 5 mai 2017

lazychaser/laravel-nestedset - how to limit depth of nested items?

I'm currently working on a project which is making use of nested categories. As is most likely obvious, there will be categories which will have parent-child relationships. To help with this, I am learning how the lazychaser/laravel-nestedset Laravel package could work.

What I would like to know is if I can limit the depth of parent categories to an arbitrary limit (e.g 5), like so:

Category 1
|__ Category 2
    |__ Category 3
        |__ Category 4
            |__ Category 5

Following on from the above description...

What would be the recommended way to make an Eloquent model rule - where I can specify an integer value for the maximum category depth? Then, perhaps catch an exception, or deal with an error in the controller if this maximum depth is already reached (when creating a category)?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire