home/bumble2020/domainwizard.net/vendor/filament/tables/src/Filters/SelectFilter.php000064400000007112150031562770024375 0ustar00placeholder(__('tables::table.filters.select.placeholder')); $this->indicateUsing(function (array $state): array { if (blank($state['value'] ?? null)) { return []; } $label = $this->getOptions()[$state['value']] ?? null; if (blank($label)) { return []; } return ["{$this->getIndicator()}: {$label}"]; }); } public function apply(Builder $query, array $data = []): Builder { if ($this->evaluate($this->isStatic)) { return $query; } if ($this->hasQueryModificationCallback()) { return parent::apply($query, $data); } if (blank($data['value'] ?? null)) { return $query; } if ($this->queriesRelationships()) { return $query->whereRelation( $this->getRelationshipName(), $this->getRelationshipKey(), $data['value'], ); } return $query->where($this->getAttribute(), $data['value']); } public function attribute(string | Closure | null $name): static { $this->attribute = $name; return $this; } /** * @deprecated Use `attribute()` instead. */ public function column(string | Closure | null $name): static { $this->attribute($name); return $this; } public function static(bool | Closure $condition = true): static { $this->isStatic = $condition; return $this; } public function searchable(bool | Closure $condition = true): static { $this->isSearchable = $condition; return $this; } public function getAttribute(): string { return $this->evaluate($this->attribute) ?? $this->getName(); } /** * @deprecated Use `getAttribute()` instead. */ public function getColumn(): string { return $this->getAttribute(); } protected function getFormField(): Select { return $this->getFormSelectComponent(); } /** * @deprecated Overwrite `getFormField()` instead. */ protected function getFormSelectComponent(): Select { $field = Select::make('value') ->label($this->getLabel()) ->options($this->getOptions()) ->placeholder($this->getPlaceholder()) ->searchable($this->isSearchable()) ->optionsLimit($this->getOptionsLimit()) ->columnSpan($this->getColumnSpan()); if (filled($defaultState = $this->getDefaultState())) { $field->default($defaultState); } return $field; } public function isSearchable(): bool { return (bool) $this->evaluate($this->isSearchable); } public function optionsLimit(int | Closure $limit): static { $this->optionsLimit = $limit; return $this; } public function getOptionsLimit(): int { return $this->evaluate($this->optionsLimit); } }