Rappasoft Datatables v1 Hello, does anyone know how could I setup date filter. Right now I am using standard way of doing it by
public function query(): Builder
{
return Model::query()->when($this->getFilter('someDate'), fn ($query, $type) => $query->where('someDate', $type))
But it constantly returns me error like this
TypeError
array_sum(): Argument #1 ($array) must be of type array, bool given
@devssi in your case, the $type always is bool,
since you are use $this-> , you can direct use it, lets use closure instead of arrow function for example
public function query(): Builder
{
return Model::when($this->getFilter('someDate'), function ($query) {
$query->where('someDate', $this->getFilter('someDate'));
});
same as
public function query(): Builder
{
return Model::query()
->when($type = $this->getFilter('someDate'), function ($query) use ($type) {
$query->where('someDate', $type);
});
@newbie360 Still the same outcome. Besides this filter I am using many more but only this one is making some issues.
this is how this column is created...
public function filters(): array
{
return [
'filterName' => Filter::make('Date')
->date(),
];
}
Am I missing something here?
@devSSI how can you pass a string to make a new model, it should be array
'filterName' => Filter::make([
'something' => '',
'something' => '',
]),
@devSSI OOPS, yeah, i guess the make() method is come from Laravel, well no idea whats problem about the package,
can you try add a info() helper to log the message
public function query(): Builder
{
return Model::query()->when($this->getFilter('someDate'), fn ($query, $type) =>
info($type);
//$query->where('someDate', $type))
Got the same issue. Did you solve it?
I'm working on an old project and I cannot update the datatables library to an earlier version...
Please sign in or create an account to participate in this conversation.