Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

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?

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.

Thanks all

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.