I have written in the Countries controller using cakephp 1.2 the following index:
class CountriesController extends AppController{
var $countryname = ‘Countries’;
public $uses = array(‘Calculation’,‘Country’);
//private $usemodel;
public function index(){
$this->set('countries', $this->Country->findAll());
$this->set('calculations', $this->Calculation->findAll());
how can i do the same in cakephp 4.x everytime it shows me error when i try to write an foreach loop in index.php file
Controller:
class CountriesController extends AppController
{
/**
* Index method
*
* @return \Cake\Http\Response|null|void Renders view
*/
public $uses = array(‘Calculation’,‘Country’);
public function index()
{
$countries = $this->paginate($this->Countries);
$this->set(compact('countries'));
$calculations = $this->paginate($this->Calculations);
$this->set(compact('calculations'));
}
is it like this correct?