JonVonWeston
JonVonWeston
FFilament
Created by JonVonWeston on 9/24/2023 in #❓┊help
Self Referencing Model and Relationship Manager
Good morning Filamites I have a table 'Products' and an associated Model - Products - nothing exciting in there I have a relationship on Products called RelatedProducts which is a hasMany relationship to self::class via a pivot table. A product can have 0 to n related products The pivot table contains product_id, related_product_id with foreign key constraints etc. I have created a relation manager on Products referring to the relatedProducts relationship - the table displays well - all good When I try and attach a product to the relatedProducts relationship via the attach action - I get 'Products::products' doesn't exist which of course it doesn't Whats the approach for a many to many relationship attachment using the relation managers? Jon
2 replies
FFilament
Created by JonVonWeston on 9/22/2023 in #❓┊help
Relation manager - embed in form?
Afternoon - is it possible to embed a relation manager in a form schema - ie tab - reading an old doc regarding Filament v3 plans it looked like it was discussed - was it ever implemented?
8 replies
FFilament
Created by JonVonWeston on 9/22/2023 in #❓┊help
Another newbie question - saving simple pivot table record
Hi folks - apologies for another newbie question - I have 2 tables - vehicle and category - relationship defined as many to many on both models - and I have a simple pivot table category_product that contains just category_id & product_id. In my create product form I have a select with items sourced from category model - all good When I save the product record - It is saving the category ID to the product table - great Back to the table display - and the column category.name isn't showing anything On investigation, the 'relationship record' in the pivot table isn't being saved - If I manually add the pivot record - boom - table is good and everyone is happy So my question is two fold Even though its a simple pivot table with no additional fields - do I need to define withPivot(['category_id','product_id']) on the models? What do I need to do to tell on create to save the relationship record? I understand that relationship record can't be created until the product has been created due to requiring the product_id I do have listeners on the product model for other reasons, so I can latch into the onCreate method in there but that feels cumbersome for something as elegant as Filament What am I doing wrong? Apologies again for these newbie questions Jon
2 replies
FFilament
Created by JonVonWeston on 9/20/2023 in #❓┊help
Advice required: Form editing / saving Parent and many children
Hi all. I'm after some advice. I have a product table and I have a product properties table - 1 product may have up to 65 properties (at present) and the majority of the properties are boolean. I want to present this information in a single form - top section is the product information and then 'n' tabs each with a number of the properties on the tab that the user may switch on or off. Once happy then I want the user to click the save button to save the parent record and then update all the property records accordingly. In my past life I would have an array <input name='product[property][index of property]' value=false> that is then sent over to receipient of the request. I hope that makes sense How would I achive this in Filament? Thanks in advance Jon
18 replies
FFilament
Created by JonVonWeston on 9/19/2023 in #❓┊help
Advice required - Relationship Management
Hi all - I'm in the process of creating a form that has a relationship (many to many) so I am using a relationship manager - when I click new related resource button in the table, I want to display a list of records in the related table that are not currently included in the relationship - so like a checkbox list - so I'm able to select multiple items in the related table and attach them to the relationship - I hope that makes sense. Whats the 'Filament' approach for doing that? Create or override the header actions of the RelationManager? Sorry for the newbie question.
3 replies
FFilament
Created by JonVonWeston on 9/14/2023 in #❓┊help
spatie media library - multiple image fields on a resource
Good morning folks - a newbie question so apologies. I have a product resource that I need to have an icon, a preview image and a gallery of images - I though that the spatie media library would enable me to do this - in my resource form schema I have the following Forms\Components\Tabs\Tab::make('Images') ->schema([ SpatieMediaLibraryFileUpload::make('preview'), SpatieMediaLibraryFileUpload::make('icon'), SpatieMediaLibraryFileUpload::make('images') ->multiple() ]), However, when I upload an image into the preview 'panel', the image is then replicated across the other File uploads - its as if they are not being treated as seperate fields. What am I doing wrong? Any advice would be greatfully received Jon
4 replies