nexxai
Unsure if plugin exists or how I'd do this if one doesn't
Ok for anyone who ends up finding this in the future, I ended up making a middleware that checks if any of the fields are null (and that they're not currently trying to access the profile edit page), and if so, redirects them to the profile edit page.
5 replies
Error when trying to sort table by MorphTo relationship
@awcodes I'm only tagging you here since you're a core maintainer of Filament and this actually seems like something that may be an issue with Filament, specifically with regards to
I did a search through the entire filamentphp GitHub organization for the term "wherehasmorph" (https://github.com/search?q=org%3Afilamentphp+wherehasmorph&type=code) and got 0 results so it at least seems possible that Filament not checking for a morphable relationship and implementing the corresponding whereHas-type lookup could be the source of at least one issue. Do you have any suggestions about what I should do next? Is this something the team would even consider looking into? I feel like I'm not the first one who would ever be trying to do something like this, but my searching isn't turning up anything that could even lead me in a direction.
whereHas
calls.
As per https://github.com/laravel/framework/pull/28928 (and linked from https://github.com/laravel/framework/issues/18523 which describes a similar - but technically not identical - issue) whereHas
doesn't work on MorphTo
relationships, and my assumption is that in the building of the table, it's doing a whereHas()
call instead of the whereHasMorph()
which was submitted in the linked PR.I did a search through the entire filamentphp GitHub organization for the term "wherehasmorph" (https://github.com/search?q=org%3Afilamentphp+wherehasmorph&type=code) and got 0 results so it at least seems possible that Filament not checking for a morphable relationship and implementing the corresponding whereHas-type lookup could be the source of at least one issue. Do you have any suggestions about what I should do next? Is this something the team would even consider looking into? I feel like I'm not the first one who would ever be trying to do something like this, but my searching isn't turning up anything that could even lead me in a direction.
9 replies
Error when trying to sort table by MorphTo relationship
Person
model:
User
model:
I've also tried with a straight hasOne
relationship on the User model, and the same thing happens.
Also of note, the table is being displayed on the PersonResource
in Filament, so I'm not sure how I would fix the pluralization; it's not going user->person/people
, it's going person->user
When you say that I "deviate from the regular naming conventions", can you explain what you mean? Like I think you mean person vs. people, but I was always under the impression that the model should be titled the singular of the noun, and the table gets named as the plural. Did I do or assume something wrong here?9 replies
Error when trying to sort table by MorphTo relationship
More notes:
- If I remove the
defaultSort()
on the name
column but then try to sort the column manually by clicking on the chevron at the top of the column, the same error shows up
- The same error also appears to affect another column on the same table which is also on the related model, strengthening my belief that it is somehow related to the MorphTo aspect of the relationship
- Other columns which are not related are sortable just fine when the chevron is clicked9 replies