Β© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filamentβ€’2y agoβ€’
3 replies
Patrick Star

RelationManager Call to undefined method HasMany::getQualifiedRelatedKeyName

Hey,

i do experience issues while implementing a RelationManager for my Filament application that i can not wrap my head around.

I do have a "Container" model that should be able to be related to other Containers - it does have a
parent_id
parent_id
column as well as a
parent
parent
(BelongsTo) &
children
children
(HasMany) relationship.

However, when i try to "put one Container into the other" by attaching it, i do get the following exception: https://flareapp.io/share/LPdKbvdm#context
I really don't understand why it does try to call
getQualifiedRelatedKeyName
getQualifiedRelatedKeyName
as this method has been removed from the Relation implementation in Laravel 5.5.

This is how i have defined the relationship column in my migration:
Schema::create('containers', function (Blueprint $table) {
    $table->id();

    $table->foreignId('parent_id')
        ->nullable()
        ->constrained('containers');

    $table->timestamps();
});
Schema::create('containers', function (Blueprint $table) {
    $table->id();

    $table->foreignId('parent_id')
        ->nullable()
        ->constrained('containers');

    $table->timestamps();
});


This is how i have implemented the relationships on the
Container
Container
Model:
class Container extends Model
{
    /**
     * The parent Container this Container is stored in.
     */
    public function parent(): BelongsTo
    {
        return $this->belongsTo(self::class, 'parent_id');
    }

    /**
     * The child Containers that are stored in this Container.
     */
    public function children(): HasMany
    {
        return $this->hasMany(self::class, 'parent_id');
    }
}
class Container extends Model
{
    /**
     * The parent Container this Container is stored in.
     */
    public function parent(): BelongsTo
    {
        return $this->belongsTo(self::class, 'parent_id');
    }

    /**
     * The child Containers that are stored in this Container.
     */
    public function children(): HasMany
    {
        return $this->hasMany(self::class, 'parent_id');
    }
}


This is how i have implemented the RelationManager:
class MyRelationManager extends RelationManager
{
    protected static string $relationship = 'children';

    public function table(Table $table): Table
    {
        return $table
            ->recordTitleAttribute('name')
            // ...
            ->inverseRelationship('parent');
    }
}
class MyRelationManager extends RelationManager
{
    protected static string $relationship = 'children';

    public function table(Table $table): Table
    {
        return $table
            ->recordTitleAttribute('name')
            // ...
            ->inverseRelationship('parent');
    }
}


Does anyone have an idea on what i am doing wrong? I do appreciate any help πŸ™‚

Thank you
Flare
Call to undefined method Illuminate\Database\Eloquent\Relations\HasMany::getQualifiedRelatedKeyName() - The error occurred at http://localhost/app/containers/1/edit
Solution
Ok, nevermind - i have to use the AssociateAction instead of the AttachAction πŸ‘€
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

Filament Resource Create/Edit BadMethodCallException Call to undefined method HasMany::associate()
FilamentFFilament / β“β”Šhelp
3y ago
Call to undefined method Staudenmeir
FilamentFFilament / β“β”Šhelp
3y ago
Call to undefined method BelongsToThrough::associate()
FilamentFFilament / β“β”Šhelp
3y ago
Call to undefined method Filament\FilamentManager::getFontWeights()
FilamentFFilament / β“β”Šhelp
3y ago