Good morning friends, I'm learning cake programming a short time ago and I'm having some difficulties.
Follow the models and controllers.
Recibo.php (Model)
class Recibo extends AppModel{
public $name = 'Recibo';
public $belongsTo = array('Loja');
public $nomeloja = 'nome';
public $nomefuncionario = 'nome';
}
Loja.php (model)
class Loja extends AppModel {
public $name = 'Loja';
public $hasOne = array('Recibos');
public $nomeloja = 'nome';
public $displayField = 'nome';
}
RecibosController.php
class RecibosController extends AppController {
public $helpers = array ('Html','Form');
public $name = 'Recibos';
public $components = array('Session');
public $uses = array('Recibos', 'Loja','Funcionario');
public function index()
{
$this->loadModel('Recibos');
$lojas = $this->Loja->find('all');
$this->set('loja',$lojas);
$this->set('recibos', $this->Recibos->find('all'));
}
Field where I display the receipt and would like to display the name of the store in front.
echo $recibo['Recibos']['loja_id'] . ' - ' . $recibo['Loja']['nome'];
What am I missing?
Well, when I click on "Notice" on the error, I check that the name and id of the store goes in the variable $loja
and not the variable $recibos
(which is what I am listing)
Thanks for the help right away.
Thanks.