Voyager: Making category's parent_id field as a dropdown, where to set the relationship method ?

Created on 9 Jan 2017  路  7Comments  路  Source: the-control-group/voyager

The TCG\Voyager\Models\Category class is located in the vendor directory, which is not advised to edit.

What is the best way to solve/accomplish this this?
btw: I've overridden the category/browse.blade.php file to display the parent category's name.

categories/browse.blade.php

All 7 comments

You can take a look at this pull request https://github.com/the-control-group/voyager/pull/496 , feel free to improve the code if you think it can be done better :)

P.S.: since it is a open source project, you can edit all files to suit your needs :)

Do you mean that I edit the packages' files located in the vendor directory locally? as you know, running composer update command will remove these changes I made.

I hope the pull request will be merged soon. In the mean time, you can edit the bread for category model to use your category model in your app. Now you can make change to category model in App namespace

screen shot 2017-01-11 at 23 11 06

Great!
Thanks @peacemoon , but when updating a category to get a null parent_id instead of a relationship, it doesn't work and the parent_id is not updated and not set as null.

I can add a category with a null parent_id, update it to get a parent category, but it can't be updated to get a null parent_id.

pull request is merged now. If you get the code from master, category dropdown should work.

Closed since it merged

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ferrywae picture ferrywae  路  4Comments

craigb88 picture craigb88  路  3Comments

vaggelis2018 picture vaggelis2018  路  3Comments

zzpwestlife picture zzpwestlife  路  3Comments

TPRAsh picture TPRAsh  路  3Comments