Doubt about views and controllers in cakephp

0

If I have 2 views, for example, greenhouses and greenhouses and the query to the database is exactly the same, do I have to create the same function twice for each one? for example

public function casasamarillas() {
    $casasamarillas = TableRegistry::get('Casas');
    $this->set('casasamarillas', $casasamarillas->find('all'));
}

public function casasverdes() {
    $casasverdes = TableRegistry::get('Casas');
    $this->set('casasverdes', $casasverdes->find('all'));
}

or I can do something like:

public function casasamarillas() {
    $casas = TableRegistry::get('Casas');
    $this->set('casas', $casas->find('all'));
}

public function casasverdes($casas) {
    $this->set('casas', $casas->find('all'));
}
    
asked by Isaac Palacio 29.06.2018 в 12:32
source

0 answers