F
Filament12mo ago
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. 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 Detailed example I have a Model Product, which has its own ProductRessource and a model History. In my History I have:
public function logable()
{
return $this->morphTo('logable');
}
public function logable()
{
return $this->morphTo('logable');
}
and in my 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 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, I receive App\Models\Product::logs(): Return value must be of type Illuminate\Database\Eloquent\Relations\HasMany, Illuminate\Database\Eloquent\Relations\MorphMany returned
Solution:
Oops. I'm stupid. It was my own typehint :x
Jump to solution
1 Reply
Solution
sven
sven12mo ago
Oops. I'm stupid. It was my own typehint :x
Want results from more Discord servers?
Add your server