I am using cakePHP version 3.x.
When i query the MessagesTable i want to get the Users data for the the sender and the receiver of the message. I have done this many times in cakePHP 2 but i cant figure out why it isn't working in version 3.x.
i have a UsersTable and a MessagesTable.
UsersTable
$this->hasMany('Messages');
MessagesTable
$this->belongsTo('Users', [
'foreignKey' => 'sender_id',
'propertyName' => 'Sender',
]);
$this->belongsTo('Users', [
'foreignKey' => 'user_id',
'propertyName' => 'Receiver'
]);
This is the query i am using
$messages = $this->Messages->find()
->where(['Messages.user_id' => $this->Auth->user('id')])
->orwhere(['Messages.sender_id' => $this->Auth->user('id')])
->order(['Messages.created' => 'DESC'])
->contain([
'Users.Pictures',
]);
I am getting the Receiver data back but not the Sender data as well. Any help would be really appreciated