Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

devSSI's avatar

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
0 likes
6 replies
newbie360's avatar

@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);
		});
devSSI's avatar

@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?

newbie360's avatar

@devSSI how can you pass a string to make a new model, it should be array

'filterName' => Filter::make([
	'something' => '',
	'something' => '',
]),
newbie360's avatar

@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))
giuseppemastrodonato's avatar

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 or to participate in this conversation.