Level 70
@umairparacha What version you are using?
It's seems already solved here: https://github.com/filamentphp/filament/discussions/6564
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am trying to add a SelectFilter on a HasMany relationship.
Here is my Resource
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('name')
->sortable()
->searchable()
])
->filters(
[
Tables\Filters\SelectFilter::make('Country')
->preload()
->relationship('addresses', 'country')
],
layout: Tables\Enums\FiltersLayout::Dropdown
);
}
Here is my Model
class User extends Authenticatable implements Authorizable, FilamentUser
{
use HasApiTokens;
use HasFactory;
use HasRoles;
use Notifiable;
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = ['password', 'remember_token'];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
'password' => 'hashed'
];
public function addresses(): HasMany
{
return $this->hasMany(UserAddress::class, 'user_id');
}
public function businesses(): HasMany
{
return $this->hasMany(UserBusiness::class, 'user_id');
}
}
Here is the Error
Filament\Forms\Components\Select::getRelationship(): Return value must be of type Illuminate\Database\Eloquent\Relations\BelongsTo|Illuminate\Database\Eloquent\Relations\BelongsToMany|Znck\Eloquent\Relations\BelongsToThrough|null, Illuminate\Database\Eloquent\Relations\HasMany returned
I found the solution on GitHub.
https://github.com/filamentphp/filament/discussions/9067#discussioncomment-7271187
Please or to participate in this conversation.