awesome-nova / dependent-filter

Dependent filters for Laravel Nova
26 stars 13 forks source link

Nova 4 support #10

Open teamappelit opened 1 year ago

teamappelit commented 1 year ago

I have installed the package and after creation of filter i have extend it with DependentFilter and got this error.

"Declaration of AwesomeNova\Filters\DependentFilter::jsonSerialize() must be compatible with Laravel\Nova\Filters\Filter::jsonSerialize(): array"

There is no support for laravel nova version 4.

gemanzo commented 3 months ago

You can simply go inside the AwesomeNova\Filters\DependentFilter class and manually add the firm to the jsonSerialize() function like this:

public function jsonSerialize(): array <-- the little piece you are missing { return array_merge([ 'class' => $this->key(), 'name' => $this->name(), 'component' => $this->component(), 'options' => count($this->dependentOf) === 0 ? $this->getOptions(app(Request::class)) : [], 'currentValue' => $this->default() ?? '', 'dependentOf' => $this->dependentOf, 'hideWhenEmpty' => $this->hideWhenEmpty, ], $this->meta()); }