Answer the question
In order to leave comments, you need to log in
How to make a hasMany query with a cast?
Tell me who knows how to make a hasMany binding with a ghost of types, I do this
public function getProjectAddress()
{
return $this->hasMany(ProjectAddress::class, ['project_id' => 'id']);
}
public function getAddress()
{
return $this->hasMany(Address::class, ['id' => 'address_id'])->via('projectAddress');
}
public function getRegion(): ActiveQuery
{
return $this->hasMany(RegionService::getRegionClassName(), ['fias_id' => new Expression('fias_id::text')])->via('address');
}
Getting unknown property: Address::fias_id::text
and
givesModel::find()->joinWish('region')
LEFT OUTER JOIN "region" ON "address". = "region"."fias_id"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question