Column from builder alias #2049
leesherwood
started this conversation in
Feature Requests
Replies: 1 comment
-
It does make sense to standardise it, perhaps an AnonymousColumn or LabelColumn would be sensible to make life simpler for a very generic label style Column. This would avoid any potential breaking changes as well. If you want to do a PR for that, then I'd be happy to review it. The standard Column shouldn't be amended in this way at this point, due to how many sites use the package, and potential impacts. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Just now I needed to add a Column with a value taken from a subquery join & alias. Why doesn't matter but for some context it was to get the latest updated_at amongst a group of models and present this in a
latest updated at
column.Pseudo-SQL-code:
The problem I hit was
Column::make('Latest Updated At', 'latest_updated_at
) would add a duplicate invalid select fieldmytable.latest_updated_at
. AndColumn::make('...', 'latestPerGroup.latest_updated_at')
would instead try to load a relationship.Luckily Anonymous Columns to the rescue, BUT that requires me to do extra code like defining how sortable would work.
Which made me wonder if there was a potential DX improvement...
Could there be a way of saying to library: "trust me bro - this column value will exist, i'll handle it". I was thinking
Column::make('...', DB::raw('latest_updated_at')
or it could be a->valueDeveloperHandled()
method.If the library just accepted that the field would be selected by the developer, and just added on the
latest_updated_at ASC/DESC
then it would work, without me needing to specify a customsortable
. Same thing could be said forsearchable
.Admittedly, it's not a huge amount of time saved, and I haven't considered the side effects, maybe it's not worth it. But figured i'd share the thought.
Beta Was this translation helpful? Give feedback.
All reactions