© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
20 replies
oodin53

Problem to attach on relationManager

Hello,

I have a problem attaching one model to another with the relationmanager.

This is my model :
class Competition extends Model
{
    public function squads()
    {
        return $this->belongsToMany(Squad::class)->join('clubs', 'club_id', '=', 'clubs.id')->orderBy('clubs.name');
    }
}
class Competition extends Model
{
    public function squads()
    {
        return $this->belongsToMany(Squad::class)->join('clubs', 'club_id', '=', 'clubs.id')->orderBy('clubs.name');
    }
}


class Squad extends Model
{
    public function club()
    {
        return $this->belongsTo(Club::class);
    }
}
class Squad extends Model
{
    public function club()
    {
        return $this->belongsTo(Club::class);
    }
}


I have a RelationManager :

class SquadsRelationManager extends RelationManager
{
    protected static string $relationship = 'squads';

    protected static ?string $recordTitleAttribute = 'clubs.name';

    public function table(Table $table): Table
    {
        return $table
            ->columns([
                Tables\Columns\TextColumn::make('club.name'),
            ])
    }
}
class SquadsRelationManager extends RelationManager
{
    protected static string $relationship = 'squads';

    protected static ?string $recordTitleAttribute = 'clubs.name';

    public function table(Table $table): Table
    {
        return $table
            ->columns([
                Tables\Columns\TextColumn::make('club.name'),
            ])
    }
}


The club names are displayed correctly on the competition edit page, but when I want to associate a new club, I do a search in the club name list, and I get an error "Undefined property: stdClass::$name".

I don't know which "name" property is causing the problem.

Is it possible to add it like I did? I'm just starting out with Filament.

Thanks for your help.
(sorry for my english)
Solution
Thank you, it's OK with this code :

Tables\Actions\AttachAction::make()
                    ->recordSelectSearchColumns(['clubs.name'])
                    ->recordTitle(fn (Squad $record): string => "{$record->club->name} ({$record->id})"),
Tables\Actions\AttachAction::make()
                    ->recordSelectSearchColumns(['clubs.name'])
                    ->recordTitle(fn (Squad $record): string => "{$record->club->name} ({$record->id})"),
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Attach action error in RelationManager
FilamentFFilament / ❓┊help
2y ago
RelationManager Attach and Detach possible values
FilamentFFilament / ❓┊help
12mo ago
Weird attach select field rendering in RelationManager
FilamentFFilament / ❓┊help
2y ago
Modify Label Options in RelationManager attach action
FilamentFFilament / ❓┊help
2y ago