Stormageddon, Dark Lord of All
Explore posts from serversEmpty 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.
error4 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
Querying a distant relationship
in my filamentPHP dashboard I have a parcelResource. each parcel has one
region
, and a state
has many regions, but I don't want the user to directly select the region, instead I want to narrow the list of regions based on the value of a selected state.
I am assuming this is done somehow with hasOneThrough
but I am not sure3 replies
Mmalefashionadvice
•Created by Stormageddon, Dark Lord of All on 1/13/2024 in #questions-and-advice
Which traditional piece to get?
![No description](https://answer-overflow-discord-attachments.s3.amazonaws.com/1195709573126950972/image.png)
3 replies
What's the best way to test a function modularly
I have this computed text column, as you can see it's pretty complicated, so I want to add some tests, problem is that I've never wrote a test before. if possible I want to test this function without relying on the UI if you get what I mean, i.e. given this input what does the function output
2 replies
When to move from different panels to user permissions.
I have the following situation:
there is an invoices resource.
admins can view and edit all invoices
users can view and create invoices assingned to them
managers view all invoices but not create new ones.
my current implementation is to create a new panel for every user type, I am wondering if implementing user roles is worth it at the moment or should I stick with the current implementation.
If I should go with user permissions what plugin should I use / does filament have a permission system of it's own?
6 replies
"Are you sure?" dialog when editing certain fields
there is a field in my form that is highly dangerous.
it's only available to super admins but i still want to make sure it only gets updated when needed
I want to show a simple are you sure model when someone attempts to save the form and they changed tha field.
2 replies