column-sortable icon indicating copy to clipboard operation
column-sortable copied to clipboard

Add support for MorphOne relationships

Open JeremyDunn opened this issue 6 years ago • 2 comments

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 avatar Feb 22 '20 19:02 JeremyDunn

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

Kyslik avatar Mar 25 '21 13:03 Kyslik

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

robbielove avatar Feb 08 '22 10:02 robbielove