Creating or Saving MorphTo relationship

I am aware of Form layout components supporting saving or creating relationship records from parent for MorphOne relationship. But I am specially facing difficulty. I have Member, User and Company models. Member has polymorphic 1:1 relationship with User and Company. I have morphable field ‘memberable’ in members table. Member can be either single user or a company. So I have a form in Member resource and I want to create member with User or Company creation from Member. How to go ahead. Below are my relationship methods.
In Member model
public function memberable():MorphTo
{
return $this->morphTo();
}


In User and Company Model

public function member():MorphOne
{
return $this->morphOne(Member::class, 'memberable');
}
In Member model
public function memberable():MorphTo
{
return $this->morphTo();
}


In User and Company Model

public function member():MorphOne
{
return $this->morphOne(Member::class, 'memberable');
}
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server