Is there a way to filter query results by `getInheritanceColumn` when the parent is also a child
corosion opened this issue · comments
Peter Kostadinov commented
Love the idea of the package but I'm running into some issues.
I have two classes, Product
and Subscription
and product
type points to itself (I saw it in the test models with the Car,
Truck
and Vehicle
).
class Product extends Model {
use HasFactory, HasChildren;
public static function childTypes():array
{
return [
'product' => self::class,
'subscription' => Subscription::class
];
}
}
class Subscription extends Product
{
use HasParent;
}
When I use Product::all()
the result is filled with products and subscriptions and when I use Subscription::all()
the result is filled only with subscription. I saw that HasParent
registers global scope which filters by the $this->getInheritanceColumn()
and I can always implement such logic in the Product
model but I was wondering Is there any method or scope that I'm missing?