What you probably want to do is override the newQuery() function on the two models in question. Something like this:
class ProductType1
{
public function newQuery($excludeDeleted = true)
{
return parent::newQuery()->whereType(1);
}
}
class ProductType1
{
public function newQuery($excludeDeleted = true)
{
return parent::newQuery()->whereType(2);
}
}
I believe newQuery()
is called in any instance where you use the query builder for that model, so that should work in all cases.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community