You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to set up a relation in my repository.
A subscription has a recipient field, which can be either a person or an institution (2 differents repositories/tables).
I've set up correct fields and methods with morphing in my Laravel Models (used to it).
But what shall I put in the 2nd argument of my make function, because by definition a morphic does not know the type by advance?
public static function related(): array {
return [
'recipient' => \Binaryk\LaravelRestify\Fields\MorphOne::make(
'recipient', PersonRepository::class)
];
}
PersonRepository::class OR InstitutionRepository::class
Repository::class ? (does not work)
This is not in the official documentation. BelongsTo and MorphOne are considered as synonymes (also in the source code), and I don't know how to advance.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello friends,
I'm trying to set up a relation in my repository.
A subscription has a recipient field, which can be either a person or an institution (2 differents repositories/tables).
I've set up correct fields and methods with morphing in my Laravel Models (used to it).
But what shall I put in the 2nd argument of my
make
function, because by definition a morphic does not know the type by advance?PersonRepository::class OR InstitutionRepository::class
Repository::class ? (does not work)
This is not in the official documentation.
BelongsTo
andMorphOne
are considered as synonymes (also in the source code), and I don't know how to advance.Thanks all
Beta Was this translation helpful? Give feedback.
All reactions