timtom
3 months ago
170
0
Laravel

Yajra DATATABLE filterColumn not working

Posted 3 months ago by timtom

Hello,

I got a problem with the filterColmun of the package Yajra datatables. I use 'addColumn' and after 'filterColumn' but it is not working, the filter does not work, all the raw is returned.

This is my code :

            DataTables::eloquent(
                $this->settlementRepository->query()
            )->addColumn('is_paid', function($settlement) {
                return ($settlement->payments()->sum('amount') >= $settlement->amount) ? 1 : 0;
            })->addColumn('total_paid', function($settlement) {
                return $settlement->payments()->sum('amount');
            })->addColumn('partner_name', function($settlement) {
                return $settlement->partner->name;
            })->filterColumn('is_paid', function ($query) {
                $query->where('is_paid', '=', 1);
            }),
                	

In the returned data i can see one raw with is_paid at 1 and one other with is_paid at 0.

Thanks

Please sign in or create an account to participate in this conversation.