SQLSTATE[22P02]: Invalid text representation: 7 ОШИБКА: неверное значение для целого числа: "parent.id"
The SQL being executed was: SELECT "c"."id", "c"."short_name" FROM "organizations_schema"."organizations" "c" LEFT JOIN "organizations_schema"."organizations" "parent" ON "c"."parent_organization" = "parent"."id" WHERE "c"."id"='parent.id'
$query->joinWith(['parentOrganization parent' => function(ActiveQuery $query){
public function getParentOrganization()
{
return $this->hasOne(Organizations::className(), ['id' => 'parent_organization']);
}
public function getParentOrganizationName()
{
$query = Organizations::find()->alias('c')->select(['c.id', 'c.short_name']);
$query->joinWith(['parentOrganization' => function(ActiveQuery $query){
return $query->andWhere(['organizations.short_name' => 'parent_organization']);
}]);
$query = $query->all();
return ArrayHelper::map($query, 'id', 'short_name');
}
public function getParentOrganizationName()
{
$query = Organizations::find()->alias('c')->select(['c.id', 'c.short_name']);
$query->joinWith(['parent_organization' => function(ActiveQuery $query){
return $query->andWhere(['organizations.parent_organization' => 'organizations.id']);
}]);
return ArrayHelper::map($query, 'id', 'short_name');
}
[
'attribute' => 'parent_organization',
'value' => 'parentOrganization.short_name',
'filter' => $searchModel->getParentOrganizationName(),
],
public function search($params)
{
$query = Organizations::find()->with('parent_organizations');
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
return $dataProvider;
}
$query->andFilterWhere(['ilike', 'short_name', $this->short_name])
->andFilterWhere(['ilike', 'organizations.short_name', $this->parent_organization]);
return $dataProvider;
}
public function getParentOrganization()
{
return $this->hasOne(Organizations::className(), ['id' => 'parent_organization']);
}
public function getOrganizations()
{
return $this->hasMany(Organizations::className(), ['parent_organization' => 'id']);
}
[
'attribute' => 'parent_organization',
'value' => 'parentOrganization.short_name',
],
Ошибка та же:
Если есть какие-нибудь идеи, буду благодарен за помощь.