MedicOneSystems/livewire-datatables

Search in Laravel 10 fails: mb_strtolower

jbajou opened this issue · 6 comments

jbajou commented

Using the search input will result in the following error on Laravel 10:

mb_strtolower(): Argument #1 ($string) must be of type string, Illuminate\Database\Query\Expression given

Any idea ?

Maybe this ‼️ #567

Maybe this ‼️ #567

It didn't fix that issue, I'm using that package

jbajou commented

I confirm, definitely not helping unfortunately...

jbajou commented

Agreed @andrecuellar
the error lies on livewire-datatables/src/Http/Livewire/LivewireDatatable.php:1358, here:

foreach ($this->getColumnFilterStatement($i) as $column) {
                                $query->when(is_array($column), function ($query) use ($search, $column) {
                                    foreach ($column as $col) {
                                        $query->orWhereRaw('LOWER(' . (Str::contains(mb_strtolower($column), 'concat') ? '' : $this->tablePrefix) . $col . ') like ?', '%' . mb_strtolower($search) . '%');
                                    }
                                }, function ($query) use ($search, $column) {
                                    $query->orWhereRaw('LOWER(' . (Str::contains(mb_strtolower($column), 'concat') ? '' : $this->tablePrefix) . $column . ') like ?', '%' . mb_strtolower($search) . '%');
                                });
                            }

I'll try to do a getValue() on it, maybe it will fix the issue.

This error appears when the Column type is a callback. When setting up the output, it can be seen that $column outputs not a string, but Illuminate\Database\Query\Expression {#2078 ▼ // app\Http\Livewire\LivewireDatatable.php:1358
#value: "CONCAT_WS('|lwdt|' ,COALESCE(summary_of_order_monitorings.order_number, ''), COALESCE(summary_of_order_monitorings.order_opening_date, ''), COALESCE(kd_engineers.number_summary_id, '')) ◀CONCAT_WS('|lwdt|' ,COALESCE(summary_of_order_monitorings.order_number, ''), COALESCE(summary_of_order_monitorings.order_opening_date, ''), COALESCE(kd_engi ▶"
}