/** * Set the constraints for an eager load of the relation. * * @param array $models */ public function addEagerConstraints(array $models) { // We'll grab the primary key name of the related models since it could be set to // a non-standard name and not "id". We will then construct the constraint for // our eagerly loading query so it returns the proper models from execution. $langKey = $this->related->getTable() . '.' . $this->langKey; $this->query->where($langKey, $this->lang); parent::addEagerConstraints($models); }