malzariey / filament-daterangepicker-filter

MIT License
97 stars 43 forks source link

Filter ignores `useColumn` #18

Closed underdpt closed 1 year ago

underdpt commented 1 year ago

Hi,

I have a complex query on a table, on which I would like to use DateRangeFilter. Due to the complexity, I have to specify the table and column to be used on the filter. This is my code:

DateRangeFilter::make('created_at')
    ->useColumn('articulos.created_at')
    ->label('Fecha de alta'),

There, useColumn is ignored and it generates a query like:

select count(*) as aggregate
from `articulos`
where (
    `articulos`.`deleted_at` is null
    and `created_at` between '2023-05-01 00:00:00' and '2023-05-31 23:59:59'
)

instead of

select count(*) as aggregate 
from `articulos` 
where (
    `articulos`.`deleted_at` is null
    and `articulos`. `created_at` between '2023-05-01 00:00:00' and '2023-05-31 23:59:59'
)

It would also be good to allow the developer to modify the query, like the included filters on Filament.

Thanks!