Skip to content

Make relationship methods public [Feature Request]  #2555

Open
@salaback

Description

@salaback

Is your feature request related to a problem?

When trying to insert relationships into models via a service provider, it is not possible because the mongo specific methods are protected. Laravel has these methods public for this reason.

Describe the solution you'd like

Swap out protected for public methods

Describe alternatives you've considered

Other than forking the package I don't see a work around.
I could create a public method on the target model which then returns the protected on, however this feels rather hacky and creates requirements on a third party package.

Additional context

Inserting a relationship via the service provider is not the most well documented features, but it is usefully for being able to decouple packages and works as follows:

public function boot(): void
{
    Parent::resolveRelationUsing('children', function ($parent) {
        return $parent->hasMany(Child::class);
    });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    relationsRelations between documents

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions