Answer the question
In order to leave comments, you need to log in
How to display contact information?
Good afternoon.
I have a messages table with messages:
id
message - message
from_whom - from whom to whom - to
whom
How to display those with whom the correspondence was conducted?
Tried to use
$this->hasOne(Users::className(), ['user_id' => 'from_whom']);
Answer the question
In order to leave comments, you need to log in
Good afternoon.
As Maxim wrote, you need to link by user id (primary key) and if you don’t have a user_id field in the Users table, then how are you going to link by it? And in the from_whom field, I hope you have the user id and field type matches the field type in the users table?
Based on standard practices, I think that you need not user_id, but just id
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question