There is no way to add a condition in on for dependency. There is such a model:
class Parent extends ActiveRecord { public function getChild() { return $this->hasMany(Child::class, ['parent_id' => 'parent_id'])->alias('c'); } }
I get the data like this:
$query = Parent::find() ->alias('p') ->distinct() ->joinWith([ 'child c' ], true, 'inner join');
As a result, the request is approximately as
select p.* from parent p inner join child c on c.parent_id = p.parent_id
The question is that I can’t figure out how to get such a request:
select p.* from parent p inner join child c on c.parent_id = p.parent_id and c.is_disabled = false