Answer the question
In order to leave comments, you need to log in
Error Trying to get property 'name' of non-object ->with() how to solve?
I have a query like:
$query = Event::find()->where(['i_user' => $_SESSION['user']['id']])
->with('category')
->with('type')
->orderBy($rsort2)
public function getCategory() {
return $this->hasOne(Category::className(), ['id' => 'i_cat']);
}
public function getType() {
return $this->hasOne(Type::className(), ['id' => 'type']);
}
<?=$ev['category']->name?></td>
<?=$ev['type']->name?></span>
$query = Event::find()->where(['i_user' => $_SESSION['user']['id']])
->with('category')
->with('type')
->orderBy($rsort2)
->asArray()
->all();
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