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}%"); })
1 Reply
awcodes
awcodes6mo ago
You can’t search on attributes because they are not part of the db scheme and all search happens at the database level. They docs cover using a virtual column to achieve this.
Want results from more Discord servers?
Add your server