Multi-tenancy for a filament page

Hi there. I have an app with multi-tenancy and it is working well with all the resources in such panel. For one resource, I had to create a new filament page (not associated with the resource) to do some simple mathematical operations. Sum of total columns and division to calculate percentages. this works great as well. The issue I have is that I cant filter the calculations by tenant. It just add all the values in the table . Can someone provide any advise please?
Solution:
Well, if I understood correctly, you needed to do a total calculation somewhere in your app and that is why I suggested the way to complete the total calculations, but yes, for multi tenancy you would need to filter your registered users model with the where condition: $total_users_count = Users::where('type', 'admin'); (of course you will change it to your own where clause as per the project needs as I am not aware of that so I gave just an example to look for an admin, but can be of course something else 😉 )...
Jump to solution
4 Replies
MilenKo
MilenKo•9mo ago
Hello @rt2214 Are there any specific reasons why you cannot have a custom page with a table and inside of the specific columns to add a function that will do the calculations using Eloquent? $something = Model::where('someting'. condition). $another = Model::where('another', condition) $column_data = $something + $another (if the need is for an arithmetical calculations) $column_data = $something . $another (for concatenaed values). And then just present the data in the panel table (I would probably do a custom page with a table and present the $custom_data where needed. I am not yet reached the point in my project but in the next few days I will be facing a similar need, so can share what I come up with (if what I think to try would work) 😉
RT2023
RT2023•9mo ago
I haven’t tried that yet. I will try but I’m afraid I will be able to do the calculations but won’t be able filter by tenant. I’ll post what I find
Solution
MilenKo
MilenKo•9mo ago
Well, if I understood correctly, you needed to do a total calculation somewhere in your app and that is why I suggested the way to complete the total calculations, but yes, for multi tenancy you would need to filter your registered users model with the where condition: $total_users_count = Users::where('type', 'admin'); (of course you will change it to your own where clause as per the project needs as I am not aware of that so I gave just an example to look for an admin, but can be of course something else 😉 )
tuto1902
tuto1902•8mo ago
Since it has been a few weeks without any more updates, I'll mark this as solved
Want results from more Discord servers?
Add your server
More Posts