Answer the question
In order to leave comments, you need to log in
How to pass parameter between links?
In I have a link QuestionUsers
'q_comp' => array(self::HAS_ONE, 'Questions', array('event_id'=>'event_id'), 'on' => 'q_comp.link_company=1'),
In Questions there is a relationship
'q_ans_comp' => array(self::HAS_ONE, 'QuestionAnswers', array('event_id'=>'event_id','question_id'=>'id'))
You need to reach QuestionAnswers, but also pass the id with QuestionUsers (in fact, you need the condition QuestionUsers .id = QuestionAnswers.user_id):
$data->q_comp->q_ans_comp->answer
Answer the question
In order to leave comments, you need to log in
The parameter can be passed using an anonymous function when requested.
Question::find()->with([
'answers' => function ($query) use ($user_id) {
return $query->where(['user_id' => $user_id]);
}
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question