King Dice
Explore posts from serversOnly last group is displaying
Hi, If I have multiple groups set in my table, only the last one will be displayed in the select. this is happening across my entire project.
for instance, here, only the
type
column will be available to group with:
the same thing if I use simple string groups:
in this case only state.name
will show up in the select menu because it's the last one.2 replies
Sum relationship
I have a User model and a Course model. with a relationship between them, this relationship is defined as "enrollment" (enrollment is basically the pivot table of the relationship)
I have made a filament resource for enrollments.
I want to get the sum of the costs of all courses
If I use the default
Sum
, I get the unique sum like so:
this currently returns the following cost of course 32 + cost of course 36
.
but what I want is to return cost of course 32 + cost of course 36 + cost of course 32
2 replies
Brainstorming ways to solve this problem
Kinda unrelated to filament, but I am going to use this feature in a filament panel so I might as well just ask here:
I am looking for a way to generate PDFs based on (1) data from my model and (2) a pre-made design. kinda like how udemy and other course sites generate custom certificates.
Here is an idea I just came up with: somehow make a bunch of templates in html & css with some parts of it being customizable then allow the user to customize the template (e.g. change the logo, color palette, etc..) and finally export it to pdf.
but I have no idea how that would work in practice.
if anyone has any better ideas/ something similar implemented in laravel or filament / a totally different idea let me know!
14 replies
How to add the owner record's name to export CSV
Hi, I have an export action, it is used on a relation manager.
I simply want to include the name of the owner record somewhere in the exported document, it could be set as the value of a column or included in the csv header. it just has to be included somewhere.
I couldn't figure it out on my own
thank you in advance
2 replies
disable detaching items only in multi-select
Hi, I have a multi select and I want to disable the detachment of elements from this multi select based on some condition. I can't use
->disabled
though cause I still need the addition of new elements to be possible2 replies
Empty hidden fields
I have two columns in my table
hours
and semesters
. both are nullable.
in my form, I have a checkbox, it's value decides whether to show the hours or the semesters input using the ->hidden
method
now I don't want both semesters and hours to be set at the same time, so for example if horus
is shown I want to make sure semesters
is null when saving the form and vice-verca4 replies
Best way to handle bulk-attaching models
I have a courses model and a users model, with a many-to-many relationship between the 2.
I need a way to attach many users at once to a certain course.
The users that need to be attached are stored in a csv with their unique IDs.
Here are a few options I came up with:
- using a CSV importer: since I have a csv I could simply import it and associate that way. the problem with this method is that configuring an importer is tedious and error prone
- here is another idea I came up with that I am not sure is possible in filament or not: having an action that opens a modal with an input field, this input field would take multiple space seperated user ids and then inserts them into the pivot table. this idea sounds good but I am not sure how to implement it
if someone could guide me on how to implement the second option or has a better idea let me know!
4 replies
resource authorization simple question
Hey in my app I have a schools resource, super admins can make,view, edit and delete any school. regular admins can create,view, edit and delete only schools that belong to one of their regions.
Initially I was using the following on the schools resource on the regular admin panel:
This worked but I incorrectly assumed that this query change would be applied to every query belonging to that resource which means that regular admins would not be able to access schools that don't belong to them. I tried to edit the URL to access one of those records assuming it would return an
403
error but it worked. so modifyQueryUsing
only affects the list view
now I understand that for this type of authorisation work I need to use model policies but in my case the policy will be practically the same for view
, viewAny
, update
and the rest of the policy methods, so is there a way to define this policy once and for all like I was doing with the modifyQueryUsing
, I hope that made sense2 replies
How to download failed rows?
Hi, I have an import action
when I click on the link to download the failed rows, I get redirected to
http://localhost:8000/filament/imports/2/failed-rows/download
and I am met with a Route [login] not defined.
error5 replies
Import Model still trying to use user_id despite specifying a different model
Hiya, I am using the import action, I have two Authenticatable models User and Admin, I changed the column name to admin_id on the imports migration but it still tries to use user_id
4 replies
Modify Query Using nested relationship
Hi, I have an institution resource, every institution belongs to a state and every state belongs to an admin.
admin ----has many---> states ---has many----> institutions
I want to only show the institutions that belong indirecly to the currently logged in admin, this is what I attempted but it didn't work:
2 replies
Manually handling many-to-many relationships
Hi, I have a many to many relationship between my Major and my Course models.
in my Course resource I used to have
I wanted to filter the list of majors available in this select based on the value of another column, I came up with this solution
but without the relationship method the form cannot be submitted properly, because filament no longer knows how to handle my majors and institutions relationship
4 replies
csv import creating data in multiple models
Hello, let's say I have a user and a course. a user can have many courses
and I have a csv with the following data.
userId
, userName
, courseName
, CourseDescription
.
in my database the relation between the courses and the user is made through the userId
, it's a one-to-many relationship
I am in the courses view in filament which has a csv import button,
if I import this csv I am assuming it will be able to fill in the userId
, courseName
and courseDescription
. but my question is: if the userId
doesn't exist in the users table, can filament also create this new user?2 replies