Find all with hasmany relation

I have cakePhp 2.5, I need to retrieve data from a table and a hasmany relation and I don’t know how to do it, I tried with joins and with contain but doesn´t show the value of the fields, it says ‘Undefined index: User’, this is the code of the controller:

And this is the code of the view:

If you debug($evento); inside your foreach loop, what does the data for one of those look like?

It looks like this:

Array ( [Eventos] => Array ( [id] => 1 [descripcion] => Abastecimiento Celula 1 - UF 1 - Nodo A [pacient_id] => [group_id] => 1 [net_id] => 1 [main_gate] => 1 [agenda_id] => 1 [observacion] => [estado] => 0 [created] => 2020-05-03 13:53:59 [modified] => 2020-05-03 13:53:59 ) [Pacient] => Array ( [id] => [name] => [lastname] => [age] => [phone] => [contact_phone] => [contact_fullname] => [address] => [institution_id] => [user_id] => [net_id] => [group_id] => [main_gate] => [status] => [statusAlert] => [inmunity_a] => [inmunity_b] => [created] => [modified] => [map_lat] => [map_long] => ) [Agendas] => Array ( [id] => 1 [descripcion] => Abastecimiento personal [created] => 2020-04-21 20:31:50 [modified] => 2020-04-21 21:19:47 ) [EventosxUser] => Array ( [0] => Array ( [id] => 1 [evento_id] => 1 [user_id] => 29 [insumo_id] => 5 [fecha_entrega] => 2020-05-03 [cantidad] => 80 [created] => 2020-05-03 13:53:59 [modified] => 2020-05-03 13:53:59 ) [1] => Array ( [id] => 2 [evento_id] => 1 [user_id] => 29 [insumo_id] => 1 [fecha_entrega] => 2020-05-03 [cantidad] => 79 [created] => 2020-05-03 13:53:59 [modified] => 2020-05-03 13:53:59 ) [2] => Array ( [id] => 3 [evento_id] => 1 [user_id] => 29 [insumo_id] => 4 [fecha_entrega] => 2020-05-03 [cantidad] => 78 [created] => 2020-05-03 13:53:59 [modified] => 2020-05-03 13:53:59 ) [3] => Array ( [id] => 4 [evento_id] => 1 [user_id] => 29 [insumo_id] => 2 [fecha_entrega] => 2020-05-03 [cantidad] => 77 [created] => 2020-05-03 13:53:59 [modified] => 2020-05-03 13:53:59 ) [4] => Array ( [id] => 5 [evento_id] => 1 [user_id] => 29 [insumo_id] => 3 [fecha_entrega] => 2020-05-03 [cantidad] => 76 [created] => 2020-05-03 13:53:59 [modified] => 2020-05-03 13:53:59 ) [5] => Array ( [id] => 6 [evento_id] => 1 [user_id] => 27 [insumo_id] => 5 [fecha_entrega] => 2020-05-03 [cantidad] => 75 [created] => 2020-05-03 13:53:59 [modified] => 2020-05-03 13:53:59 ) [6] => Array ( [id] => 7 [evento_id] => 1 [user_id] => 27 [insumo_id] => 1 [fecha_entrega] => 2020-05-03 [cantidad] => 74 [created] => 2020-05-03 13:53:59 [modified] => 2020-05-03 13:53:59 ) [7] => Array ( [id] => 8 [evento_id] => 1 [user_id] => 27 [insumo_id] => 4 [fecha_entrega] => 2020-05-03 [cantidad] => 73 [created] => 2020-05-03 13:53:59 [modified] => 2020-05-03 13:53:59 ) [8] => Array ( [id] => 9 [evento_id] => 1 [user_id] => 27 [insumo_id] => 2 [fecha_entrega] => 2020-05-03 [cantidad] => 72 [created] => 2020-05-03 13:53:59 [modified] => 2020-05-03 13:53:59 ) [9] => Array ( [id] => 10 [evento_id] => 1 [user_id] => 27 [insumo_id] => 3 [fecha_entrega] => 2020-05-03 [cantidad] => 71 [created] => 2020-05-03 13:53:59 [modified] => 2020-05-03 13:53:59 ) [10] => Array ( [id] => 11 [evento_id] => 1 [user_id] => 31 [insumo_id] => 5 [fecha_entrega] => 2020-05-03 [cantidad] => 70 [created] => 2020-05-03 13:54:00 [modified] => 2020-05-03 13:54:00 ) [11] => Array ( [id] => 12 [evento_id] => 1 [user_id] => 31 [insumo_id] => 1 [fecha_entrega] => 2020-05-03 [cantidad] => 69 [created] => 2020-05-03 13:54:00 [modified] => 2020-05-03 13:54:00 ) [12] => Array ( [id] => 13 [evento_id] => 1 [user_id] => 31 [insumo_id] => 4 [fecha_entrega] => 2020-05-03 [cantidad] => 68 [created] => 2020-05-03 13:54:00 [modified] => 2020-05-03 13:54:00 ) [13] => Array ( [id] => 14 [evento_id] => 1 [user_id] => 31 [insumo_id] => 2 [fecha_entrega] => 2020-05-03 [cantidad] => 67 [created] => 2020-05-03 13:54:00 [modified] => 2020-05-03 13:54:00 ) [14] => Array ( [id] => 15 [evento_id] => 1 [user_id] => 31 [insumo_id] => 3 [fecha_entrega] => 2020-05-03 [cantidad] => 66 [created] => 2020-05-03 13:54:00 [modified] => 2020-05-03 13:54:00 ) ) )

And I need to retrieve data from several tables, not only EventosxUser.

Can you edit that and add a line with nothing but three backticks (```) before all the data? That will let it format in a readable way.

I found the solution for this issue, thank you the same for the help.