Unexpected NULL rows and sort direction loss when sorting FilamentPHP table columns by relationship attributes
0 reputation · 22 Jun 2022, 13:38 UTC
When configuring a FilamentPHP table column to sort by a related model attribute using $table->column('user.name', 'User Name')->sortable(), the goal is to understand if the generated query includes the necessary join for the relationship and how rows with null foreign keys are ordered.
Uncertainty remains about whether the join is added automatically in Filament 3.2+ or must be declared manually, and whether the sort direction stored in the URL persists after a page reload when the relationship column is used.
Does enabling sortable() on a BelongsTo column automatically add a LEFT JOIN in Filament 3.2+, or must I manually join the relationship? How does the presence of NULL foreign keys affect the order of rows when sorting ascending versus descending? Does the sortDirection URL parameter persist after a page reload when sorting by a relationship column?