© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
2 replies
Sven

MorphMany Relations not (yet) supported in V3 relationshipManager?

Hey!

TL/DR


The docs state
These are compatible with HasMany, HasManyThrough, BelongsToMany, MorphMany and MorphToMany relationships.
These are compatible with HasMany, HasManyThrough, BelongsToMany, MorphMany and MorphToMany relationships.
on https://filamentphp.com/docs/3.x/panels/resources/relation-managers#relation-managers---interactive-tables-underneath-your-resource-forms but when creating a RelationManager for a morphed relation, I receive
App\Models\Product::logs(): Return value must be of type Illuminate\Database\Eloquent\Relations\HasMany, Illuminate\Database\Eloquent\Relations\MorphMany returned
App\Models\Product::logs(): Return value must be of type Illuminate\Database\Eloquent\Relations\HasMany, Illuminate\Database\Eloquent\Relations\MorphMany returned


Detailed example


I have a Model
Product
Product
, which has its own
ProductRessource
ProductRessource
and a model
History
History
. In my History I have:

    public function logable()
    {
        return $this->morphTo('logable');
    }
    public function logable()
    {
        return $this->morphTo('logable');
    }


and in my
Product
Product
I have

    public function logs(): HasMany
    {
        return $this->morphMany(History::class, 'logable');
    }
    public function logs(): HasMany
    {
        return $this->morphMany(History::class, 'logable');
    }


In my
LogRelationManager
LogRelationManager
I added

class LogRelationManager extends RelationManager
{

    protected static string $relationship = 'logs';
class LogRelationManager extends RelationManager
{

    protected static string $relationship = 'logs';


But when opening my
ProductResource
ProductResource
, I receive

App\Models\Product::logs(): Return value must be of type Illuminate\Database\Eloquent\Relations\HasMany, Illuminate\Database\Eloquent\Relations\MorphMany returned
App\Models\Product::logs(): Return value must be of type Illuminate\Database\Eloquent\Relations\HasMany, Illuminate\Database\Eloquent\Relations\MorphMany returned
Managing relationships - Panel Builder - Filament
Solution
Oops. I'm stupid. It was my own typehint :x
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

MorphMany Relation buggy in relationshipManager.
FilamentFFilament / ❓┊help
3y ago
does filament v3 supported spa ?!
FilamentFFilament / ❓┊help
3y ago
relationship select morphMany
FilamentFFilament / ❓┊help
3y ago
MorphToSelect in Repeater (Mdue to MorphMany)
FilamentFFilament / ❓┊help
3y ago