Closed gitkv closed 5 years ago
The solution to this problem:
In the file src/HasParent.php
on line 26 add concatenation with the name of the table.
$query->where($instance->getTable().'.'.$instance->getInheritanceColumn(), $instance->classToAlias(get_class($instance)));
<?php
trait HasParent
{
//...
public static function bootHasParent()
{
//...
static::addGlobalScope(function ($query) {
$instance = new static;
if ($instance->parentHasHasChildrenTrait()) {
$query->where($instance->getTable().'.'.$instance->getInheritanceColumn(), $instance->classToAlias(get_class($instance)));
}
});
}
//...
}
Do you mind submitting a PR?
I'm not against. But now you need to solve a lot of current problems. I will do as liberation.
I created PR #51
Thanks for the PR - merged and tagged: v0.7.1
Hi, I have the following problem.
I have 2 models: InvoiceItem - parent
InvoiceItemSubscribe - children, have scopeForAct method
I execute the query:
query to sql:
Postgress return:
[2019-07-09 11:07:34] [42702] ERROR: column reference "product_type" is ambiguous
I wanted to fix this by adding a prefix to the table name in the $childColumn variable
This of course solves the ambiguity problem. But with this fix, your package stops working, when all records are requested by the parent model, instances of the parent model are returned, but the children are expected.
I expect instance
I get instance