I’m starting to use the cakephp, and developing something like the blog tutorial, but instead of a article i got a document.
Here is the deal, each document has a User who added and who modified.
My association is defined by:
Blockquote
//DocumentsTable
$this->belongsTo(‘Users’)
->setProperty(‘created_user’)
->setForeignKey(‘created_userid’)
->setJoinType(‘INNER’);
$this->belongsTo('Users')
->setProperty('modified_user')
->setForeignKey('modified_userid')
->setJoinType('INNER');
Blockquote
When i’m filtering and then debug my return date, he only returns 1 modified_user, but i need the created_user too.
Blockquote
object(App\Model\Entity\Document) {
'id' => (int) 18,
'title' => '12121',
'edition' => '12122112',
'created_userid' => (int) 5,
'modified_userid' => (int) 6,
'created' => object(Cake\I18n\FrozenTime) {
'time' => '2017-09-21T18:31:02+00:00',
'timezone' => 'UTC',
'fixedNowTime' => false
},
'modified' => object(Cake\I18n\FrozenTime) {
'time' => '2017-09-21T18:31:02+00:00',
'timezone' => 'UTC',
'fixedNowTime' => false
},
'modified_user' => object(App\Model\Entity\User) {
'id' => (int) 6,
'username' => 'admin2',
'password' => '$2y$10$vegLxxmcJwUJb6F7j4X3l.d.rUDCOmtYQPJ2U9pLl0Ua5AX8jM8Z.',
'role' => 'admin',
'created' => object(Cake\I18n\FrozenTime) {
'time' => '2017-09-20T18:42:33+00:00',
'timezone' => 'UTC',
'fixedNowTime' => false
},
'modified' => object(Cake\I18n\FrozenTime) {
'time' => '2017-09-21T16:08:40+00:00',
'timezone' => 'UTC',
'fixedNowTime' => false
},
'[new]' => false,
'[accessible]' => [
'*' => true,
'id' => false
],
'[dirty]' => [],
'[original]' => [],
'[virtual]' => [],
'[errors]' => [],
'[invalid]' => [],
'[repository]' => 'Users'
},
'[new]' => false,
'[accessible]' => [
'title' => true,
'edition' => true,
'created' => true,
'modified' => true
],
'[dirty]' => [],
'[original]' => [],
'[virtual]' => [],
'[errors]' => [],
'[invalid]' => [],
'[repository]' => 'Documents'
}
Blockquote
Someone can explain me how it should work?