Hey I am trying to find a solution I am retrieving the data from mysql using this command :
$meals = TableRegistry::get('Users');
$query = $meals
->find()
->select(['id' ,'username'])
->where(['role' => 'patient']);
$data = $query->toArray();
This is my code after using query->toarray() I am getting this value
{ "id": 4, "username": "s2" }
I want to put this value in my form which is like this :
echo $this->Form->input('user_id', [
'options' => [1 => 'Admin', 2 => 'Author']
]) ;
How to use foreach to get value as id and usernmae as name any quick solution