TextColumn searchable function anomaly.

Hello, I am using the TextColumn's ->searchable() function, and I've modified the query. When I test the search and enter the search parameter, the table is empty, even though it should return records. I tested the MySQL query directly, and it works, returning the correct records. I also used dd() on the query with ->get() at the end, and it returned the correct results. The column value is also a custom value. What could be the issue? Can anyone help me?
TextColumn::make('quantity')
->label(__('Quantity'))
->searchable(query: function ($query, $search) {
return $query->join('order_lines', 'orders.id', '=', 'order_lines.order_id')
->join('products', 'order_lines.product_id', '=', 'products.id')
->select('orders.*')
->groupBy('orders.id')
->havingRaw('SUM(order_lines.quantity) LIKE ?', ["%{$search}%"]);
})
->getStateUsing(function (Order $record) {
return $record->products->sum('order_line.quantity');
})
->sortable(),
TextColumn::make('quantity')
->label(__('Quantity'))
->searchable(query: function ($query, $search) {
return $query->join('order_lines', 'orders.id', '=', 'order_lines.order_id')
->join('products', 'order_lines.product_id', '=', 'products.id')
->select('orders.*')
->groupBy('orders.id')
->havingRaw('SUM(order_lines.quantity) LIKE ?', ["%{$search}%"]);
})
->getStateUsing(function (Order $record) {
return $record->products->sum('order_line.quantity');
})
->sortable(),
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server