jeudi 17 mai 2018

Laravel get parent items

I have a menu setup using https://github.com/harimayco/wmenu-builder and it's working quite well until it comes to trying to display the permalinks by getting the menu items parent but for it to keep going to get all parents.

Here is an example of the menu:

+-----+---------------------------------------------------------------------------------+--------------------------------------------------------------------------------+--------+
| id  | label                                                                           | link                                                                           | parent |
+-----+---------------------------------------------------------------------------------+--------------------------------------------------------------------------------+--------+
|   1 | Home                                                                            | homepage                                                                       |      0 |
|   2 | About Us                                                                        | about-us                                                                       |      0 |
|   3 | Services for you                                                                | services-for-you                                                               |      0 |
|   5 | Education                                                                       | education                                                                      |      0 |
|   6 | Services for business                                                           | services-for-business                                                          |      0 |
|   7 | Our People                                                                      | our-people                                                                     |      0 |
|   8 | Contact us                                                                      | contact-us                                                                     |      0 |
|   9 | Careers                                                                         | careers                                                                        |      0 |
|  10 | Press and Events                                                                | press-and-events                                                               |      0 |
|  27 | Care Home Funding                                                               | care-home-funding                                                              |      3 |
|  28 | Contentious Probate                                                             | contentious-probate                                                            |      3 |
|  29 | Financial Provisions                                                            | financial-provisions                                                           |     28 |
|  30 | Negligence Claims                                                               | negligence-claims                                                              |     28 |
|  31 | Proprietary Estoppel                                                            | proprietary-estoppel                                                           |     28 |
|  32 | Rectification Claims                                                            | rectification-claims                                                           |     28 |
|  33 | Trust Disputes                                                                  | trust-disputes                                                                 |     28 |
|  34 | Validity Claims                                                                 | validity-claims                                                                |     28 |
|  35 | Court of Protection                                                             | court-of-protection                                                            |      3 |
|  36 | Deputyship Applications                                                         | deputyship-applications                                                        |     35 |
|  37 | Financial Abuse                                                                 | financial-abuse                                                                |     35 |
|  38 | Gifts                                                                           | gifts                                                                          |     35 |
|  39 | Professional Deputyships                                                        | professional-deputyships                                                       |     35 |
|  40 | Purchasing and Adapting a Property                                              | purchasing-and-adapting-a-property                                             |     35 |
|  41 | Statutory Wills                                                                 | statutory-wills                                                                |     35 |
|  42 | Support for Solicitors                                                          | support-for-solicitors                                                         |     35 |
|  43 | Criminal Law                                                                    | criminal-law                                                                   |      3 |

So for instance, I want to get the permalink structure of Financial Provisions this has a parent id of 3 so the final permalink structure would be:

/services-for-you/contentious-probate/financial-provisions

I can't for the live of me workout the best way of doing this, do I just create a relationship of it's self?

Can any help or shed any light on this.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire