I have 2 tables one of images that belong to several different tables and in the other table the reference for id_image with the id of the table images.
In the image model I put:
$this->hasOne('Documentos')
->setName('Documentos')
->setDependent(true);
And in the model of the table I put:
$this->belongsTo('Imagenes')
->setForeignKey('id_imagen');
In theory with this I relate the 2 tables but I do not know if I'm doing it right.
Then another doubt that I have to show the name of the image, which is a field within the table of images called image would have to do something like $Documentos->imagen;
I use the latest version of CakePHP