F
Filament2y ago
qcol

Two repeaters in one resource?

Hi! Please advise me on how to approach such an issue: I have tables: items (id, name), sets (id, name, item_id), orders (id, name), order_items (id, order_id, item_id, set_id default NULL). As for the order_items structure, I'm not quite sure. What I want to achieve is that on the edit order page, I have the option to add a single item or a set of items (of my choice). This is because an order can consist of both single items and sets. Of course, later on I will need a report of what all the items the order consisted of (both single items and items from sets). I am wondering how to build resource Orders to allow the addition of both single elements and sets? Using the built-in tools (Repeater divided into tabs?) or will I need some sort of custom page?
2 Replies
Dan Harrin
Dan Harrin2y ago
you should use a morphto relationship on order_items instead of separate item_id and set_id alternatively, you should separate out the relationship to be order_items and order_sets the first approach will allow you to collate the data in one table. the second approach will be easier to calculate with. once you've sorted that, create a HasMany relationship from Order to OrderItem pivot model, then you can use a repeater. if you go with a morphTo on the pivot model, you can use a MorphToSelect in the repeater to select an item OR set
qcol
qcolOP2y ago
Thank you very much for your quick reply Dan, now I have full clarity. Once again I am convinced that Filament has no limits. Thank you for this tool!
Want results from more Discord servers?
Add your server