0
Good morning friends, I am learning to program on cake recently and I am having some difficulties.
Follow 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?
Because, when I click on "Notice" in the error I verify that the name and id of the store goes in the variable $loja
and not in the variable $recibos
(which is the one I’m listing)
Thanks in advance for the help.
Thanks.
Cool my namesake Paulo. That’s right. I’m just starting out in cakephp, this is my second project. Thanks for your help.
– Punisher07