Replies: 5 comments 3 replies
-
|
I have the same question |
Beta Was this translation helpful? Give feedback.
-
|
Looks line this is not documented, but the following does the trick (example from my code): |
Beta Was this translation helpful? Give feedback.
-
|
Hi buddy, I have the same problem and I found a workaround You can create a method on morph model (Comment), who will deliver the attribute conditionally. You need to setup this method as attribute. Source: https://laraveldaily.com/post/filament-table-dynamic-column-other-columns-accessor Edit: You can also do it this way: Tables\Columns\TextColumn::make('cpf_cnpj')
->getStateUsing(fn($record) => $record->isPeople() ? $record->customerable->cpf : $record->customerable->cnpj) |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
I stumbled upon this discussion because I had the same challenge. In the end I solved it like this: My scenario: Several models use tags. I want a tag edit page to show all models this tag is connected to. In order for this to work, you need a TagTaggable pivot model. My TaggableRelationManager attached to the TagResource: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a one-to-many polymorphic relationship: e.g. a Comment for either a Post or a Video.
For my
Commentmodel I have method$comment->commentable()that returns either aPostor aVideo.For my Filament
CommentResourceI created a relationship managerCommentableRelationManager.But how do define the table columns so that they show either the columns relevant for the
Postor the ones relevant for theVideo?I could not find it in the documentation.
Updated: my request may have been confusing. I want to define the table for my
CommentableRelationManager. So, when I open a comment in myCommentResource, I see the related object that the comment was for: either aPost(with e.g. a textarea field) or aVideo(with e.g. a dimensions field). How do I define the form/table in thatCommentableRelationManager? Can it be used by bothPostandVideo?Beta Was this translation helpful? Give feedback.
All reactions