Skip to content

Add support for MorphOne relationships - #143

Open
JeremyDunn wants to merge 1 commit into
Kyslik:L6from
JeremyDunn:morphone-support
Open

Add support for MorphOne relationships#143
JeremyDunn wants to merge 1 commit into
Kyslik:L6from
JeremyDunn:morphone-support

Conversation

@JeremyDunn

Copy link
Copy Markdown

This PR adds support for sorting by a polymorphic MorphOne relationship. This change is pretty straight-forward as it only requires an extra condition to the join query.

Let me know if you have any questions or would like me to revise or add anything.

@JeremyDunn
JeremyDunn requested a review from Kyslik February 22, 2020 19:22
@Kyslik

Kyslik commented Mar 25, 2021

Copy link
Copy Markdown
Owner

I need someone to verify this PR before it can go in.

@robbielove

Copy link
Copy Markdown

I rebased this branch onto the latest (I need to use PHP 8) and tried it but found that an error occurred when using the morphOne relation:

    public function subdomains(): MorphOne
    {
        return $this->morphOne('Example\Subdomain', 'subdomainable', 'subdomainable_type', 'subdomainable_id')->orderBy('created_at', 'desc')->withoutGlobalScopes();
    }

Screen Shot 2022-02-08 at 7 57 53 pm

https://github.com/robbielove/column-sortable/tree/morphone-support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants