martes, 3 de marzo de 2020

Issues with display FK Data in CakePHP

I'm trying to display the actual value as opposed to the ID Number using cakePHP. These are my Tables Roles Table Users Table l This is my UsersTable code class UsersTable extends Table { public function initialize(array $config) { $this->hasOne('Roles'); } This is my UsersController code public function list() { $usersTable = $this->Users->find('all')->contain(['Roles']); $allUsers = $usersTable->toArray(); $this->set("allUsers", $allUsers); } This is how im trying to print it $user->role->name However I am getting the following error Error What am I doing wrong and how do I fix this issues?
http://dlvr.it/RRBM4d

No hay comentarios:

Publicar un comentario