column-sortable
column-sortable copied to clipboard
Add support for MorphOne relationships
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.
I need someone to verify this PR before it can go in.
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();
}
https://github.com/robbielove/column-sortable/tree/morphone-support