Formfeed-UK / nova-breadcrumbs

Augments Nova 4 Breadcrumbs with nesting and resource/static override methods
MIT License
19 stars 8 forks source link

Usage with `parent` in Model but no `BelongsTo::make` on Resource #41

Closed mrleblanc101 closed 7 months ago

mrleblanc101 commented 7 months ago

Currently, my breadcrumbs is constructed from the first BelongsTo::make found on the Resource. This resource is not shown in the main menu, and can only be create via relationship. I don't want to add a BelongsTo as it adds a field when I create the Resource via a relationship (default to the viaResourceId value but still). So instead, I create a parent() public method on my Model, but it does nothing. Am I misunderstanding something ? How would I hide the field and still have the proper breadcrumbs.

mrleblanc101 commented 7 months ago

Oh, I think I can just use ->hide() on the BelongsTo field. But I'm not sure why the plugin doesn't just take the first ->belongsTo in the Model instead of the Resource, or the public function parent() if it's defined, but I'm pretty new to this so I might be confusing some things.

mrleblanc101 commented 7 months ago

BelongsTo::make(...)->hide() doesn't work after all because Nova won't fill or save the value if it's hidden. So I get an error.

mrleblanc101 commented 7 months ago

Ah, firgured it out. I was duplicating my belongsTo like so:

Screenshot 2024-02-15 at 4 03 19 PM

Instead of referencing the existing belongsTo:

Screenshot 2024-02-15 at 4 03 30 PM

Even thought it's very clear in the documentation. https://github.com/Formfeed-UK/nova-breadcrumbs?tab=readme-ov-file#general