AdviceProtocol
and Question
which you the tables advice_protocols
and questions
. The models have been linked together by:public function userGoal() {
return $this->hasOne('App\Question', 'id', 'user_goal_id');
}
I would like to get the following variabels from my query: the advice protocol name, the advice protocol category and questions name. The two tables are linked through a set of ids
. The query which I have now is:public function data(){
$advicePreparationsQuery = AdviceProtocol::select(['advice_protocols.name', 'advice_protocols.category', 'questions.id'])
->join('questions', 'advice_protocols.user_goal_id', '=', 'questions.id')
->get();
The questions.id
can be retrieved, but when I change the variable to questions.name
: nothing is retrieved. My output doesn't give an error, but no values are returned. Could someone please help me to get the value of questions.name
?via Anna Jeanine