Probably an edge case kind of bug. However its always good to report it 馃檪
categories:
label: Categories
searchable: true
sortable: true
relation: categories
select: name
Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'categories' in 'order clause' (SQL: select `expenses`.* from `expenses` where `expenses`.`deleted_at` is null order by `categories` desc limit 40 offset 0)
--
聽 | File: /public_html/website/vendor/laravel/framework/src/Illuminate/Database/Connection.php
聽 | Line: 664
categories:
label: Categories
searchable: true
sortable: true
export: true
relation: categories
select: name
Of course the most easy solution would be to set sortable -> false. However it would be great if it's still possible to sort on a related column.
P.S. Setting sortable -> true on a column that gets overruled with get[Column]Attribute() defined in the model doesn't work. Can we make this work too? I know this would be hard because of pagination, maybe define a custom sort query? 馃檪
P.S. Setting sortable -> true on a column that gets overruled with get[Column]Attribute() defined in the model doesn't work. Can we make this work too? I know this would be hard because of pagination, maybe define a custom sort query? 馃檪
If what you want is to sort on the final value returned by the getter, that's not going to be easy because sorting runs in the database level. However if you want to be able to sort by the DB value but present a different value to the user that's easy by just using type: partial and rendering whatever data you feel like.
Most helpful comment
Fixed by https://github.com/octobercms/october/commit/18af35d928956b3ebae636a0996add74d683bec8