Joachim Strand
Tenant user pivot values
Hey, I have a fairly standard tenant setup and I have a users resource to show the tenant users. My "tenant" is a Company. So a company
belongsToMany
Users and a users belongsToMany
Companies with the pivot table having a column role
.
Listing the users is working just fine, but the role is not showing (or none of the pivot values).
This is the relationship on the Users model:
I have the same thing on the Company model, just the reverse users()
.
I have a pivot class that is casting the role to a enum and the added_by_user_id
is a relationship to a user.
I understand that I have to convert the enum into a string, but if I add TextColumn::make("role")
to the table, I expected to get an error saying something like cannot convert enum to string, but I get this instead:
App\Models\User::role must return a relationship instance, but "null" was returned. Was the "return" keyword used?
Am I missing something essential here? I use pivot values many places like this, but this one was not working.
Let me know if you need more data
Thank you!2 replies
Reset custom table header action modal form
Hi, I have a table header action with a form on a modal that works great. I recently wanted to add a "add and create another" submit button to the modal since I found myself saving and adding again alot.
This is my table header action button placed in the
->headerActions()
of the table.
I followed the instructions on how to add button, but how can I reset the form? You can see in the action that I tried many options, but none are working.
`
Anyone experienced this and have solved it? 🙂
Thank you for your help!4 replies
Reset the form and don't close the modal
In the documentation (https://filamentphp.com/docs/3.x/actions/modals#adding-an-extra-modal-action-button-to-the-footer) if I want to add a footer action to a modal that works like the "create and create another", I can create an action and add an argument to check for that, but in that argument it just sais a comment
// Reset the form and don't close the modal
. How do I do that? how can I prevent the modal from closing? Or atleast have it reopen with a blank form?5 replies