searchable attribute

I created an attribute that combines the first name and last name of the customers relationship. This makes the column unsearchable.

protected function getFullNameAttribute(): array { return $this->customers->map(function ($customer) { return $customer->FirstName . ' ' . $customer->LastName; })->unique()->all(); }

I tried making is searchable based off the filament documentation like this but this doesn't work either. I'm probably doing something stupid. Any chance someone has done something similar and got this working?

TextColumn::make('full_name') ->label('Users') ->badge() ->searchable(query: function (Builder $query, string $search): Builder { return $query ->where('customer.FirstName', 'like', "%{$search}%") ->orWhere('customer.LastName', 'like', "%{$search}%"); })
Was this page helpful?