subtract 2 column table
Hello, i have 2 column like this
i want to subtraction between Quota and Terisi, and make only 1 column. How can i achieve that in Filament? Thank you!
16 Replies
Hi, you can try this
Or append an attribute to your model like this
and use it like this
Hello Charles! Thank you for being so concerned with my question. I appreciate that!
I already tried the first but it shows nothing.
Do you get a error message with the first solution ?
@charleswilfriedk there is no error message in the first, but i try to modified and only show $this->participant_count, seems like it shows nothing
Hum.. ok and the 2nd solution ?
For the first solution i tried something similar and it should be working.
Can you verify that this works correctly :
quota column is working fine, the participant_count isn't working
if using this, is shown up
Ok i see where the problem is!
I think that i should be 'participants' if the relationship is hasMany or belongsToMany. Try this :
I tried this but still shows nothing @charleswilfriedk
I'm sorry if this question takes your precious time
this is your code with ClassChoice model
Don't worry about this! I rely on help from the discord from time to time too
Ok first the relationship type is hasMany so change the name to 'participants'
Thank you so much! I'm really appreciate for your help!
Only works if the relation name is correct
so the relation name must plural, participants?
yes that's the best practice for hasMany and belongsToMany relationships
the count() at the end only works if the return type of $record->participants is a collection
You're right, thank you so much for your help!
Solution
Now this is work, @charleswilfriedk thank youuu!!!
relation name must plural because using hasMany
Ok good! Happy to help.